Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include static library within a preprocessor directive

I'm using Visual Studio 2012.

I used many times preprocessor directives like

#ifdef something 
      #include<some_header.h>
#else
      #include<other_header.h>
#endif

I was wondering if is possible to link a static library in a similar way:

#ifdef something 
      // use some_library.lib
#else
      // use other_library.lib
#endif

The question, came from the subject of my previous question: I have two static libraries lib1.lib, lib2.lib (not their code) without namespaces, with the same function-prototypes, but with different implementations.

like image 795
888 Avatar asked Mar 19 '13 15:03

888


1 Answers

If you are using MSVC you can do

#ifdef something 
      #pragma comment(lib,"xxx.lib")
#else
      #pragma comment(lib,"zzz.lib")
#endif

In GCC you cannot do this.

like image 102
Tony The Lion Avatar answered Nov 10 '22 00:11

Tony The Lion