Search code examples
androidconditional-compilationdead-code

supress warnings: dead code and conditional compilation


I often declare some constants to conditionally compile/not compile chunks of code. I put these constants on one class, then I use them all along the (big) app code.

Conf.java

    public static final int GUI_ACTIONBAR_HEIGHT=0;

elsewhere (example):

super.onCreate(savedInstanceState, Conf.GUI_ACTIONBAR_HEIGHT==0?R.layout.activity_funq_play_noactionbar:R.layout.activity_funq_play, true);

However, this triggers a warning "comparing identical expressions" in the case shown. It's obviously something I can live with, but I'd like to know if there's any SupressWarning magic to get rid of it (and the yellow warning icon in the sourcecode).

@SupressWarnings ("unused") 

doesnt't do the trick.


Solution

  • This is a Java compilation warning and toggling it on/off really depends on the IDE. Assuming you are using Eclipse, you can navigate to the configurations by Preferences > Java > Compiler > Errors/Warning > Comparing identical values ('x==x') 'ignore' This should turn it off.