开发者

how to strip a code inside a compile time macro after making a build

开发者 https://www.devze.com 2023-01-13 21:55 出处:网络
I do have say #if A in code a开发者_如何学JAVAnd made a lib. Now for some reason i do want to take out code from lib containing #if A without recompiling the lib.

I do have say #if A in code a开发者_如何学JAVAnd made a lib.

Now for some reason i do want to take out code from lib containing #if A without recompiling the lib.

Can i do this using some command.

Regards, Kiran


So you're saying you had a .c file like this:

<list of code>
#if A
 <optional code>
#endif

And you compiled this .c file to a compiled library (a .lib, .dll, .so, .o or .a), and you want to remove the <optional code> from the compiled library? It can't be done, because the #if A directive doesn't exist in the compiled library; it is statically processed at compile time (in theory, before compile during preprocessing) and either wholly included or wholly excluded from the compiled library. The only way to change it is to recompile.


Just don't use a macro, use a variable.

0

精彩评论

暂无评论...
验证码 换一张
取 消