Run preprocessor only but with only for certain statements

前端 未结 5 1109
-上瘾入骨i
-上瘾入骨i 2020-12-29 07:49

I have a number of debug statements defined in a program, and I want to be able to make a copy of the source without these statements.

In order to do this I first lo

5条回答
  •  无人及你
    2020-12-29 08:37

    gcc -E -nostdinc test.c produces

    # 1 "test.c"
    # 1 ""
    # 1 ""
    # 1 "test.c"
    # 9 "test.c"
    int main( int argc, char* argv[] )
    {
    
    
        puts( "Hello, World!" );
    
        return 0;
    }
    

    and an error to stderr

    test.c:1:19: error: no include path in which to search for stdio.h
    

    You can easily filter out the # lines ... and re-add the includes.

提交回复
热议问题