audacity icon indicating copy to clipboard operation
audacity copied to clipboard

(Useless?) CONST macro causes many warning messages

Open carlo-bramini opened this issue 3 years ago • 0 comments

libraries\lib-screen-geometry\ZoomInfo.h declares a CONST macro in this way:

#ifdef __GNUC__
#define CONST
#else
#define CONST const
#endif

Here it is the point where it is defined:

https://github.com/audacity/audacity/blob/93493c3752a495c3ed201231d878715765a5382e/libraries/lib-screen-geometry/ZoomInfo.h#L17

This macro is used just in 3 points:

https://github.com/audacity/audacity/blob/93493c3752a495c3ed201231d878715765a5382e/libraries/lib-screen-geometry/ZoomInfo.h#L142 https://github.com/audacity/audacity/blob/93493c3752a495c3ed201231d878715765a5382e/src/tracks/playabletrack/wavetrack/ui/WaveformView.cpp#L292 https://github.com/audacity/audacity/blob/93493c3752a495c3ed201231d878715765a5382e/src/tracks/playabletrack/wavetrack/ui/WaveformView.cpp#L293

When compiling with MinGW-w64, it happens that lot of source files print this message on the console:

/home/Carlo/audacity/libraries/lib-screen-geometry/ZoomInfo.h:18: warning: "CONST" redefined
   18 | #define CONST
      |

This happens because CONST is defined by windef.h system include on Windows. MinGW W32APIs, since they mimic the behaviour of Microsoft SDK, also provides the CONST. But since MinGW is GCC, the CONST macro is redefined to empty and this shows the message above. Instead MSVC, which is not GNU, defines CONST to const, which is the same declaration into windef.h and for this reason it does not print warnings. It is just quite annoying to have this warning every time you compile a source, so I was wondering if this CONST macro is really required or not and it could be removed if it is not needed.

carlo-bramini avatar Jul 24 '22 05:07 carlo-bramini