If you want to compare C structures using
memcmp
you must just ensure that the structures does not contain padding bytes. How to do this depends on the used compiler.
With the Microsoft compiler use
pack[
^]:
#pragma pack(push, 1)
struct exmp {
char a;
char b;
};
#pragma pack(pop)
With GCC use the
packed
attribute (see
Common Type Attributes - Using the GNU Compiler Collection (GCC)[
^]):
struct __attribute__ ((__packed__)) exmp {
char a;
char b;
};