The Oracle Developer Studio C and C++ compilers have their own built-in implementations of the C preprocessor that are used by default. These preprocessors have the following extensions which are compatible with gcc.
The Oracle Developer Studio preprocessors:
#warning
#include_next (to implement wrapper headers)
Some code that depends on traditional mode behavior of the preprocessor will also encounter differences between the Oracle Developer Studio and GCC compilers. The traditional mode in gcc is described at https://gcc.gnu.org/onlinedocs/cpp/Traditional-Mode.html.
Although you can achieve traditional behavior using /usr/lib/cpp on Oracle Solaris if you require that behavior, the best practice is to replace those dependencies with more modern usages. /usr/lib/cpp is not intended to be a fully gcc-compatible preprocessor.
The following examples show the output that are sometimes seen in source code.
Example 1 Token-Pasting Using Empty CommentsFOO/**/BAR
The expected result is “FOOBAR” in the output. This does not work in either gcc or Oracle Developer Studio unless you take special steps to enable traditional mode. In Oracle Developer Studio C, this means specifying the –Xs option. In gcc, you must specify the –traditional-cpp option. It is better to update the code to use the standard ## token-pasting operator defined in C and C++.
Example 2 Inter-Token Spacing#define FOO foo #define BAR bar FOO-BAR
The expected output here is “FOO-BAR”, not “FOO - BAR”. The preprocessor might or might not add extra spaces around the '-' symbol. The gcc compiler does not add spaces, and some code depends on that behavior when using the compiler as a preprocessor with the –E or –P options. To get the traditional behavior, you can use –Xs with the Oracle Developer Studio C compiler (not supported in Oracle Developer Studio C++) or you can use /usr/lib/cpp directly.