Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler version, name, and OS detection in C++

I need to detect the OS name, compiler name, and version of the compiler with C++, as I need to change the setup for each case.

How can I do that?

like image 725
prosseek Avatar asked Dec 22 '22 19:12

prosseek


2 Answers

For most compilers you can find a list of predefined macros.

  • VS http://msdn.microsoft.com/en-us/library/b0084kay%28v=vs.80%29.aspx
  • gcc http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
like image 198
Elalfer Avatar answered Dec 26 '22 07:12

Elalfer


I recommend define platform in build scripts by providing -D_i386 -DENDIAN=1234 -D_linux. But if you still think another predef project is your friend:

http://sourceforge.net/apps/mediawiki/predef/index.php?title=Main_Page

like image 29
gavenkoa Avatar answered Dec 26 '22 07:12

gavenkoa