View Full Version : preprocessor conditionals on g++ version
monkeyking
November 24th, 2008, 01:20 AM
Is it possible to do preprocessor conditionals on the version of gcc. like
#if GCC_version< 4.0
#define old_defines
#endif
Futhermore is it possible to have diffent #defines for differnet platforms,
thanks if advance
snova
November 24th, 2008, 02:02 AM
Yes. The macro is __GNUC__. I think there's another one.
There are also predefined macros for differing architecures, but I don't know what they are except 'i386'.
PaulFr
November 24th, 2008, 04:21 AM
Perhaps http://gcc.gnu.org/onlinedocs/gcc-4.1.2/cpp/Common-Predefined-Macros.html will help.
monkeyking
November 25th, 2008, 12:31 AM
I solved this,
for anyone reading this, a complete list of defines can be given with
echo "main(){}" | g++ -E -x c++ -dM -
The solution is this
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
/* Test for GCC > 3.2.0 */
#if GCC_VERSION > 30200
But I can only make the compareson work for the ">" not "==" or "<".
This must be an error of mine?
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.