I want to get only preprocessed version of file.cc
. I did g++ -E file.cc
, got:
# 1 "file.cc"
# 1 "<command-line>"
# 1 "file.cc"
What did I do wrong?
In computer science, a preprocessor (or precompiler) is a program that processes its input data to produce output that is used as input to another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers.
When the C preprocessor is used with the C, C++, or Objective-C compilers, it is integrated into the compiler and communicates a stream of binary tokens directly to the compiler's parser. However, it can also be used in the more conventional standalone mode, where it produces textual output.
The preprocessor is a text substitution tool that modifies the source code before the compilation takes place. This modification is done according to the preprocessor directives that are included in the source files.
4.3 Preprocessing source files If this file is called 'test. c' the effect of the preprocessor can be seen with the following command line: $ gcc -E test. c # 1 "test.
Assumed that your source file contains a simple main function:
$ cat file.cc
int main() {
return 0;
}
Then, with the command you showed, the output looks like this:
$ g++ -E file.cc
# 1 "file.cc"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "file.cc"
int main() {
return 0;
}
The output which is shown in the question happens when file.cc
is empty. Note that "empty" means that the file can still contain comments, or #ifdef
blocks with a condition which evaluates to false - since the preprocessor filters them out, they do not appear in the output either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With