|
Boost Users : |
From: Eric Lemings (lemings_at_[hidden])
Date: 2007-02-23 16:50:11
Greetings,
I was wondering if the following can be done with Boost Preprocessor.
Given a list of preprocessor macro names, write a simple program that
prints whether each macro is defined and its value if it is defined.
In particular, I'd like to know if the following example program could
be reduced/simplified with Boost:
#include <iostream>
using namespace std;
#define STRING(x) #x
#define STRINGIZE(x) STRING(x)
#define IS " is "
#define NOT "not "
#define DEFINED "defined."
#define VALUE " Its value is "
extern int
main () {
#if defined __mips
cout << STRING(__mips) IS DEFINED;
cout << VALUE STRINGIZE(__mips) << endl;
#else
cout << STRING(__mips) IS NOT DEFINED << endl;
#endif
#if defined __unix
cout << STRING(__unix) IS DEFINED;
cout << VALUE STRINGIZE(__unix) << endl;
#else
cout << STRING(__unix) IS NOT DEFINED << endl;
#endif
#if defined __sgi
cout << STRING(__sgi) IS DEFINED;
cout << VALUE STRINGIZE(__sgi) << endl;
#else
cout << STRING(__sgi) IS NOT DEFINED << endl;
#endif
#if defined _COMPILER_VERSION
cout << STRING(_COMPILER_VERSION) IS DEFINED;
cout << VALUE STRINGIZE(_COMPILER_VERSION) << endl;
#else
cout << STRING(_COMPILER_VERSION) IS NOT DEFINED << endl;
#endif
#if defined __GNUC__
cout << STRING(__GNUC__) IS DEFINED;
cout << VALUE STRINGIZE(__GNUC__) << endl;
#else
cout << STRING(__GNUC__) IS NOT DEFINED << endl;
#endif
return 0;
}
Thanks,
Eric.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net