...
| 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 | ||||
|---|---|---|---|---|
| ||||
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 | ||||
|---|---|---|---|---|
| ||||
#ifdef PLATFORM1 memcpy(dest, src, 12); #else memcpy(dest, src, 24); #endif |
...