Include static library in preprocessor directive

I am using Visual Studio 2012.

I used multiple preprocessor directives like

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

I was wondering if it 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 was from the topic of my previous question : I have two static libraries lib1.lib, lib2.lib (and not their code) without namespaces, with the same prototype functions, but with different implementations.

+6
source share
1 answer

If you use MSVC, you can do

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

You cannot do this in GCC.

+7
source

All Articles