Why would somebody use an #if 1 C preprocessor directive?

前端 未结 9 2084
谎友^
谎友^ 2020-12-10 01:42

I am looking through some C source code and I don\'t understand the following part

#if 1

   typedef u         


        
9条回答
  •  感动是毒
    2020-12-10 02:45

    The cleaner way of doing it is probably doing something like:

    #if ALGO1
    
    #else
    
    #endif
    

    But, you will have to pass in ALGO1 to the compiler args somewhere...for example in a makefile, you need to add -DALGO1=1 (if no 1 is provided, 1 is assumed). Ref: http://www.amath.unc.edu/sysadmin/DOC4.0/c-compiler/user_guide/cc_options.doc.html

    This is more work...so, usually, for quick checks, #if 1 is used. And in some cases, forgotten and left behind as well :-)

提交回复
热议问题