Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
In this noncompliant code example \[[GCC Bugs|http://gcc.gnu.org/bugs.html#nonbugs_c]\], the author uses preprocessor directives to specify platform-specific arguments to {{memcpy()}}. However, if {{memcpy()}} is implemented using a macro, the code results in undefined behavior. 

Code Block
bgColor#FFCCCC
langc
memcpy(dest, src,
#ifdef PLATFORM1
  12
#else
  24
#endif
);

...

Wiki Markup
In this compliant solution \[[GCC Bugs|http://gcc.gnu.org/bugs.html#nonbugs_c]\], the appropriate call to {{memcpy()}} is determined outside the function call.

Code Block
bgColor#ccccff
langc
#ifdef PLATFORM1
  memcpy(dest, src, 12);
#else
  memcpy(dest, src, 24);
#endif

...