@related : [[C]] [[C++]] [[Programming]] [[MSVC]] === THE C PREPROCESSOR & ITS LANGUAGE=== === PREPROC === #define max2(a,b) ( (a>b) ? a : b ) #define max3(a,b,c) ( max2( (max2(a,b) , c ) ) #ifndef __cplusplus #error A C++ compiler is required #endif printf("DATE=%s, TIME=%s\n", _ _ DATE _ _, _ _ TIME _ _); //Jun XX XXXX, 15:01:32 printf("FILE=%s, LINE=%d\n", _ _ FILE _ _, _ _ LINE _ _ ); //main.cpp, line: 133 #define Str(x) #x #define Xstr(x) Str(x) #define OP plus char *opname = Xstr(OP); #define Paste(a, b) a##b === [[C++]] Wrap=== #ifdef __cplusplus extern "C" { #endif /* ... C code ... */ #ifdef __cplusplus } // extern "C" #endif === [[MSVC]]=== #ifdef _MSC_VER // msvc-6.0 does declare var outside's for scope #define for if (true) for #endif // _MSC_VER ===USING C PREPROC AND C++ TEMPLATES=== How to use C Preprocessor on some template parameter ? I'm afraid C Preproc process before the C++ one ... if we can say that I needed a such thing to provide "switch on type facilities" : #include #include using namespace std; #define cdebug cout /** * @author: www.philippe.COVAL.online.fr * PROJECT=preproc; make ${PROJECT} ; ./${PROJECT} ; rm ./${PROJECT} **/ #define STR(x) #x template class Cls { public: Cls(T* in=0) : ptr_(in) { type_=STR(T); } T* ptr_; char* type_; }; int main(int argc, char* argv[[]]) { cdebug< a; cdebug< #include #include using namespace std; #define cdebug cout /** * @author: www.philippe.COVAL.online.fr * PROJECT=typeid; make ${PROJECT} ; ./${PROJECT} ; rm ./${PROJECT} **/ template class Cls { public: Cls(T* in=0) : ptr_(in) { //type_= typeid(T); // how to use this ? type_name_= typeid(T).name(); } type_info type_id() { return typeid(T); } T* ptr_; const char* type_name_; //type_info type_; // how to use this ? }; int main(int argc, char* argv[[]]) { Cls a; cdebug< > b; cdebug<