How to include <windows.h> and "WM.h" in simulation, without having warnings about WM_ macros redeclarations?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • How to include <windows.h> and "WM.h" in simulation, without having warnings about WM_ macros redeclarations?

    I'm trying to arrange a simulation under Windows. I started from the example downloaded from emWin evaluation package.

    If I include both (from Windows OS) and "WM.h" (from emWin), I have some warnings about macros redeclarations:

    C Source Code

    1. src\emWin/WM.h:206:0: warning: "WM_PAINT" redefined [enabled by default]


    Of course, those macros are used in Windows libraries too.

    I found the example in the emWin evaluation package add -w option to gcc compiler. It inhibits all the warnings from compiler, and this isn't an ideal setup.

    Is there a method to include both and "WM.h" without having warnings?
  • Hi,

    The messages defined in emWin are exactly the same as in WIN32:

    WM.h (emWin):
    #define WM_PAINT 0x000F /* Repaint window (because content is (partially) invalid */

    winuser.h (WIN32)
    #define WM_PAINT 0x000F

    Because the defines are exactly the same the compiler should not show a warning here. WM.h and windows.h can be used together. We could not find any problem here when opening the evaluation project and including windows.h together with WM.h.

    Regards, Jörg
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Because the defines are exactly the same the compiler should not show a warning here.
    I don't know what is your compiler, but gcc emits this kind of warning, even if the value of macro is the same.

    Have you tried gcc under Windows for simulation? Of course, without suppressing all the warnings.
  • I found what is the problem.

    I'm using mingw compiler and winuser.h contains the following macro:

    C Source Code

    1. #define WM_CREATE 1



    emwin WM.h file contains:

    C Source Code

    1. #define WM_CREATE 0x0001



    Of course they are the same integer value, but they are different macro definitions.