Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Corrected the CS to use != instead of ==

...

Code Block
bgColor#ccccff
langc
struct timer {
  unsigned char MODE;
  unsigned int DATA;
  unsigned int COUNT;
};

#if (sizeof(struct timer) =!= (sizeof(unsigned char) + sizeof(unsigned int) + sizeof(unsigned int)))
  #error "Structure must not have any padding"
#endif

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

 Bibliography

[Becker 2008] 
[Eckel 2007] 
[ISO/IEC 9899:2011]Section 6.7.10, "Static Assertions"
[Jones 2010] 
[Klarer 2004] 
[Saks 2005] 
[Saks 2008] 

...