You are here:

C++/Compiler Directives Removal



I have a lot of Pre-Processor compiler directives in my source code. I want to remove some of those from the source, but I want an automated way to do that. I don't know any software which can this.

Basically, if I have the following sample source code:
#if (COMPILING_WAY == 3)
nPeople = 33;

I want an automated way to convert all my source code to the way the compiler would see it if COMPILING_WAY == 3. That means:
nPeople = 33;

..instead of the previous sample.

I hope I made it clear enough.

Thanks in advance.

Compilers usually have more than one pass through the code. The first pass usually is to do what you want. They usually have an option to let you export the intermediate files.
Therefore, depending on the compilet that you use, find the way you can tell the compiler to save the file after it passes the first pass (that is after it converts macros to codes).
You might even be able to ask compiler to save the assembly language corresponding to your code. That happend usually in the second pass of compiling.
The last pass is linker that converts assembly to machine code.
I hope this helps.


All Answers

Answers by Expert:

Ask Experts




You may ask me about simple to complicated C/C++ programming methods/style and most like questions about network programming in C++.


I'm a professional programer in C++ and network/internet programming.

©2016 All rights reserved.