I have put all the structures in a header file named structure.h:
struct mac_filter {
u_char ether_dhost[ETHER_ADDR_LEN];
u_char ether_shost[ETHER_ADDR_LEN];
u_short ether_type;
}__attribute__ ((packed));
When I compile structure.h I get the following errors:
error: expected specifier-qualifier-list before ‘u_char’
u_char ether_dhost[ETHER_ADDR_LEN];(line at which there is an error )
error: expected specifier-qualifier-list before ‘u_int16_t’
u_int16_t uh_sport;(line at which there is an error )
How do I resolve these errors?
If it worked before you started moving things around, it’s most likely because
u_charandu_int16_tare not defined at that point.Change the types temporarily to
intand see if the problem disappears (though you may see other problems because of that).If so, change them back and ensure that the types are defined before you try to use them. For example, check that the headers are included in the right order to do this. If you were to post the code, it would make it a lot easier to tell you exactly how to fix it.
And I hesitate to ask this since it sounds condescending. You’re not actually trying to compile the header file on its own, are you? I ask simply because of your “when I compiled that structure.h” comment. If you are, you shouldn’t be. You should be compiling C files which
#includeheader files.Apologies if I’ve offended, that wasn’t my intention. It’s just that I’ve seen the wondrous things that some people try to do, and that make sense to them 🙂