/* This is a C Style comment */ //Do NOT use these, which are C++ Style Comments
if (something == this) { Do some stuff; } else if (otherstuff == whatever) { Do some more stuff; }
#if 0 int functionGoesHere(void) { return; } #endif
typedef struct { unsigned char element; /**< Document this element */ unsigned int anotherElement; /**< Document this element */ } struct_name_t;
unsigned
int
allows a 32-bit machine to use naturally aligned words for instance, as it can use a 32-bit unsigned
int
. Typically structs which are part of a protocol will require the use of stdint.h types (uint8_t
, uint16_t
, etc)stdint.h
type, and not shorter versions (ie: don't typedef
uint8_t
u8
for laziness). This is more cosmetic.The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined.
/// Router Solicitation Message Type _PACKSTART typedef struct { uint8_t type; /**< ICMPv6 Type (133) */ uint8_t code; /**< ICMPv6 Code (0) */ uint16_t checksum; /**< ICMPv6 Checksum */ uint32_t reserved; /**< Reserved field */ } _PS fip_nd6_rs_t; _PACKEND
-fshort-enums
option so the enum is not allocated in an integer (ie: 16 bits) but may fit in something smaller.#define do_something(a, b) {a = b + 5;\ b = 6 * a;}
fip_
, as they are all part of the fip module. Consider the macro fip_packet_getFromIP6Hdr_nextHeader()
: fip_packet_getFromIP6Hdr_nextHeader() ^ ^ ^ ^ | | | | | | | +---- Operates on the next header field | | | | | +------------------ Gets a certain field from the IPv6 header. There may | | be a number of macros/functions in the 'getFromIP6Hdr' | | series, getting different fields. | | | +---------------------------- Part of the packet buffer module. Should be found in | either fip_packet.c or fip_packet.h | +--------------------------------- FIP is highest-level module