Visual Studio ignores the code inside #if DEBUG / RELEASE scope and doesn't check for errors or autocompletes

前端 未结 3 1988
无人及你
无人及你 2021-01-12 23:54

I\'ve been writing an #if DEBUG, #else, #endif fragment of code, and I noticed that Visual Studio doesn\'t let me use autocomplete to

3条回答
  •  逝去的感伤
    2021-01-13 00:35

    At the beginning of the file define both constant:

    #define DEBUG
    #define RELEASE
    

    Next, use two if condition instead of if/else.

    #if DEBUG
                // autocomplete works
    #endif
    #if RELEASE
                // autocomplete works
    #endif
    

    Of course, you must delete/comment out these defines before compiling the project.

    In my opinion, this awkward and fraught with mistakes.

提交回复
热议问题