K&R style declaration

W

westymatt

void
capture_callback(buffer, packet_header, data)
u_char *buffer, const struct pcap_pkthdr *packet_header,
u_char *data;
{
.....
}

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 â->â

I am not sure how to form this declaration. I know I don't have to
use k&r, but I would just like to know.
 
T

Tim Prince

void
capture_callback(buffer, packet_header, data)
u_char *buffer, const struct pcap_pkthdr *packet_header,
u_char *data;
{
.....
}

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 â->â

I am not sure how to form this declaration. I know I don't have to
use k&r, but I would just like to know.
K&R didn't support const, so it would have to be omitted. Only recently
has gcc begun to get strict about combining K&R code where const is
unspecified with std C where it is specified, breaking the builds where
warnings are treated as fatal.
BTW, the strange characters are likely due to your not setting an
environment variable such as LANG=C.
 
B

Ben Pfaff

Tim Prince said:
....
K&R didn't support const, so it would have to be omitted.

I think that the real problem here is that the commas in the list
of declarations should be semicolons. ISO C does not forbid use
of const in K&R-style function parameter declarations.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Compiling fics-1.7.4 3
RSA implementation issues in public key pem loader function 0
p 145 K&R 14
K&R p 130 29
K&R 1-24 15
K&R exercise 1-18 10
Remove repeated words from a file 3
Mini Web Server in C++ (Part One) 4

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top