D
dave_140390
Hi,
Is there a clean way to determine at compile-time whether your compiler
supports the __func__ feature?
I mean, something similar to the following (which tests for the
existence of macro __LINE__):
#ifdef __LINE__
(code that uses __LINE__)
#else
(code that doesn't use __LINE__)
#endif
This technique cannot be used for __func__, because __func__ is a
variable, not a macro.
In theory, you could use this:
#if __STDC__ && __STDC_VERSION__ >= 199901L
(code that uses __func__)
#else
(code that doesn't use __func__)
#endif
Unfortunately, some pre C99 compilers already support __func__, and
some supposedly C99 compilers do not yet support __func__.
So, are we condemned to write tests such as:
#if (some version of compiler 1) || (some version of compiler 2) || ...
(code that uses __func__)
#else
(code that doesn't use __func__)
#endif
-- dave
Is there a clean way to determine at compile-time whether your compiler
supports the __func__ feature?
I mean, something similar to the following (which tests for the
existence of macro __LINE__):
#ifdef __LINE__
(code that uses __LINE__)
#else
(code that doesn't use __LINE__)
#endif
This technique cannot be used for __func__, because __func__ is a
variable, not a macro.
In theory, you could use this:
#if __STDC__ && __STDC_VERSION__ >= 199901L
(code that uses __func__)
#else
(code that doesn't use __func__)
#endif
Unfortunately, some pre C99 compilers already support __func__, and
some supposedly C99 compilers do not yet support __func__.
So, are we condemned to write tests such as:
#if (some version of compiler 1) || (some version of compiler 2) || ...
(code that uses __func__)
#else
(code that doesn't use __func__)
#endif
-- dave