Tapatalk

How to turn off default setting of user defined macro in DLL compilation

How to turn off default setting of user defined macro in DLL compilation

12
Basic UserBasic User
12

    Sep 30, 2015#1

    This question regards to user defined macro in DLL file compilation.

    Assuming I have the following codes in a DLL file:

    Code: Select all

    #ifndef USERMACRO_DECL
    	# define USERMACRO_DECL
    #endif
    When I build the DLL file, I have the following message:

    Code: Select all

    warning: "USERMACRO_DECL" redefined [enabled by default]
    This is fine for most needs, I am just wondering where in UEStudio I can turn this off, as sometimes we may choose to not define the macro for different build requirements.

    Thanks again.

    6,685587
    Grand MasterGrand Master
    6,685587

      Oct 01, 2015#2

      First of all, a macro already defined should not be redefined. If this must be done, then the code should be:

      Code: Select all

      #ifdef USERMACRO_DECL
      #undef USERMACRO_DECL
      #define USERMACRO_DECL whatever
      #endif
      See also Undefining and Redefining Macros in GCC online documentation. There are always one or more pretty methods to avoid a warning. It would be also possible to use a diagnostic pragma to avoid a specific warning in a specific file. I don't recommend to disable any warning. I suggest the opposite, enable all warnings supported by a compiler, especially for new projects, i.e use -Wall -Wextra for GCC/MinGW.

      The GCC page about Warning Options lists all basic options related to warnings and contains the links to the other warning options.

      I can see in the configuration files for MinGW compiler that some of those options were made customizable via the Build - Set Compiler Options dialog. And there is an additional Warnings = in group COMPILER OPTIONS to add additional warning options not explicitly listed in group C/C++ Warning Options. GCC respectively its Windows port MinGW usually outputs on a warning also the option which can be used to suppress this warning. Add this option on Warnings = in compiler options dialog. I suppose the option for this warning is -Wno-macro-redefined, but I have not studied GCC documentation to verify my assumption.
      Best regards from an UC/UE/UES for Windows user from Austria

      12
      Basic UserBasic User
      12

        Oct 01, 2015#3

        Thank you for your generous comments as always. :).