Is there a way to get VS2008 to stop warning me about unreachable code?

前端 未结 8 1931
我在风中等你
我在风中等你 2021-02-05 02:04

I have a few config options in my application along the lines of

const bool ExecuteThis=true;
const bool ExecuteThat=false;

and then code that

8条回答
  •  再見小時候
    2021-02-05 02:31

    Well, #pragma, but that is a but grungy. I wonder if ConditionalAttribute would be better - i.e.

    [Conditional("SOME_KEY")]
    void DoThis() {...}
    [Conditional("SOME_OTHER_KEY")]
    void DoThis() {...}
    

    Now calls to DoThis / DoThat are only included if SOME_KEY or SOME_OTHER_KEY are defined as symbols in the build ("conditional compilation symbols"). It also means you can switch between them by changing the configuration and defining different symbols in each.

提交回复
热议问题