|
|
| Next: [News] IBM Figures Show That Linux Pays Off |
| Author |
Message |
westymatt External

Since: Jul 15, 2007 Posts: 5
|
Posted: Wed Jul 18, 2007 7:19 am Post subject: GCC problem Archived from groups: comp>os>linux>development>system (more info?) |
|
|
I switched my code over to using what I believe to be the K&R style
function definitions.
63 /*pcap_loop callback routine*/
64 void
65 capture_callback(buffer, packet_header, data)
66 u_char *buffer, const struct pcap_pkthdr
*packet_header, u_char *data;
67 {
68 total_captured_packets++;
69 if (display == true)
70 {
71 fprintf(stdout, "Received packet %d\n");
72 }
73 if (cache_packets == true)
74 {
75 struct packetCache *pc;
76 if ((pc = malloc(sizeof *pc + packet_header->len)) ==
NULL)
77 {
78 fprintf(stderr, "Memory Allocation Error!\n");
79 fprintf(stderr, "Turning off caching\n");
80 cache_packets = false;
"packman.c" 230L, 5444C written
sysadmin@devbox:~/projects/packet_capture$ gcc -c packman.c
packman.c: In function âcapture_callbackâ:
packman.c:66: error: expected identifier or â(â before âconstâ
packman.c:76: error: invalid type argument of â->â |
|
| Back to top |
|
 |
Ulrich Eckhardt External

Since: Jul 30, 2004 Posts: 83
|
Posted: Wed Jul 18, 2007 9:16 am Post subject: Re: GCC problem [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
westymatt wrote:
> I switched my code over to using what I believe to be the K&R style
> function definitions.
That would be incredibly stupid. The simple reason is that it's
old&deprecated and non-standard. Any compiler worth its name should reject
it, unless explicitly instructed to do otherwise.
Uli |
|
| Back to top |
|
 |
Mike McGInn External

Since: Jul 18, 2007 Posts: 1
|
Posted: Wed Jul 18, 2007 10:31 am Post subject: Re: GCC problem [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
On Wed, 18 Jul 2007 07:19:17 +0000, westymatt wrote:
> I switched my code over to using what I believe to be the K&R style
> function definitions.
>
> 63 /*pcap_loop callback routine*/
> 64 void
> 65 capture_callback(buffer, packet_header, data)
> 66 u_char *buffer, const struct pcap_pkthdr
> *packet_header, u_char *data;
> 67 {
> 68 total_captured_packets++;
> 69 if (display == true)
> 70 {
> 71 fprintf(stdout, "Received packet %d\n");
> 72 }
> 73 if (cache_packets == true)
> 74 {
> 75 struct packetCache *pc;
> 76 if ((pc = malloc(sizeof *pc + packet_header->len)) ==
> NULL)
> 77 {
> 78 fprintf(stderr, "Memory Allocation Error!\n");
> 79 fprintf(stderr, "Turning off caching\n");
> 80 cache_packets = false;
> "packman.c" 230L, 5444C written
> sysadmin@devbox:~/projects/packet_capture$ gcc -c packman.c
> packman.c: In function âcapture_callbackâ:
> packman.c:66: error: expected identifier or â(â before âconstâ
> packman.c:76: error: invalid type argument of â->â
You should buy the second edition before doing that.
--
Mike McGinn
"more kidneys than eyes!" |
|
| Back to top |
|
 |
Gil Hamilton External

Since: Jan 08, 2007 Posts: 22
|
Posted: Wed Jul 18, 2007 1:16 pm Post subject: Re: GCC problem [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
westymatt <westymatt RemoveThis @gmail.com> wrote in news:1184743157.214777.263570
@z28g2000prd.googlegroups.com:
> I switched my code over to using what I believe to be the K&R style
> function definitions.
As others have already noted, that's not a terribly sane thing to do. I
really can't imagine why you would want to do so. However gcc will still
happily accept the code if you give it proper K&R syntax.
> 63 /*pcap_loop callback routine*/
> 64 void
> 65 capture_callback(buffer, packet_header, data)
> 66 u_char *buffer, const struct pcap_pkthdr
> *packet_header, u_char *data;
The function arguments should be separated by semicolons:
void capture_callback(buffer, packet_header, data)
u_char *buffer;
const struct pcap_pkthdr *packet_header;
u_char *data;
{
/* function body */
}
Also, you should know that the keywords "const" and "void" did not exist
back in original K&R days.
GH |
|
| Back to top |
|
 |
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|