I am using VScode.
As far as I know, cpp.exe is a preprocessor and g++ is a compiler.
When preprocessing the source code with cpp.exe, an exe file was created, and when I used VScode, I could see that the source code was attached a lot.
How do I compile after preprocessing the source code first?
>Solution :
The cpp.exe program is indeed a preprocessor, and the g++ program is a compiler. To compile a C++ source code file after preprocessing it, you can use the g++ program along with the -E flag to tell g++ to preprocess the source code file and then stop, without actually compiling it.
Here is an example of how you can use g++ to preprocess and compile a C++ source code file called main.cpp:
# Preprocess the main.cpp file
g++ -E main.cpp > main.i
# Compile the preprocessed file
g++ main.i -o main.exe
This will preprocess the main.cpp file using g++, and then save the preprocessed source code to a file called main.i. The g++ command will then compile the main.i file, creating an executable file called main.exe.
Alternatively, you can use the -save-temps flag with g++ to tell it to save the preprocessed source code to a file automatically, without the need to redirect the output of the preprocessor to a file. Here is an example of how you could use this flag to preprocess and compile main.cpp:
# Preprocess and compile main.cpp
g++ -save-temps main.cpp -o main.exe
This will preprocess main.cpp, and then save the preprocessed source code to a file called main.i. g++ will then compile main.i and create the main.exe executable file.
