Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.88k stars 323 forks source link

dcraw.cc compiler warnings #4875

Open Thanatomanic opened 6 years ago

Thanatomanic commented 6 years ago

When I try to build RT on Win10 using an up to date MSYS2, I was used to getting the following message:

C:/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:15:2: warning: #warningPlease include winsock2.h before windows.h [-Wcpp]
 #warning Please include winsock2.h before windows.h
  ^~~~~~~

However, recently (unsure as to when exactly), two more warnings started popping up.

C:/msys64/home/Roel/rt-dev/rtengine/dcraw.cc:91: warning: "strcasecmp" redefined
 #define strcasecmp stricmp

In file included from C:/msys64/mingw64/include/glib-2.0/glib/gtestutils.h:30,
                 from C:/msys64/mingw64/include/glib-2.0/glib.h:85,
                 from C:/msys64/home/Roel/rt-dev/rtengine/dcraw.cc:14:
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:120: note: this is the location of the previous definition
 #define strcasecmp _stricmp

C:/msys64/home/Roel/rt-dev/rtengine/dcraw.cc:92: warning: "strncasecmp" redefined
 #define strncasecmp strnicmp

In file included from C:/msys64/mingw64/include/glib-2.0/glib/gtestutils.h:30,
                 from C:/msys64/mingw64/include/glib-2.0/glib.h:85,
                 from C:/msys64/home/Roel/rt-dev/rtengine/dcraw.cc:14:
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:119: note: this is the location of the previous definition
 #define strncasecmp _strnicmp

Seems pretty harmless, but I guess it would be nicer if it didn't happen.

TooWaBoo commented 6 years ago

I don't get these two more warnings. Did you do a clean compilation?

Thanatomanic commented 6 years ago

Forgot to mention that this only happens when I make a debug build (or relwithdeb)

Thanatomanic commented 6 years ago

After some digging, I believe that the #define's in dcraw.cc are not necessary. The header string.h is included, which already contains this tidbit:

#ifndef NO_OLDNAMES
  char *__cdecl strdup(const char *_Src) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
  int __cdecl strcmpi(const char *_Str1,const char *_Str2) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
  int __cdecl stricmp(const char *_Str1,const char *_Str2) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
  char *__cdecl strlwr(char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
  int __cdecl strnicmp(const char *_Str1,const char *_Str,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
  int __cdecl strncasecmp (const char *, const char *, size_t);
  int __cdecl strcasecmp (const char *, const char *);
#ifndef __CRT__NO_INLINE
  __CRT_INLINE int __cdecl strncasecmp (const char *__sz1, const char *__sz2, size_t __sizeMaxCompare) { return _strnicmp (__sz1, __sz2, __sizeMaxCompare); }
  __CRT_INLINE int __cdecl strcasecmp (const char *__sz1, const char *__sz2) { return _stricmp (__sz1, __sz2); }
#else
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif /* !__CRT__NO_INLINE */
  char *__cdecl strnset(char *_Str,int _Val,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
  char *__cdecl strrev(char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
  char *__cdecl strset(char *_Str,int _Val) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
  char *__cdecl strupr(char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
#endif

So the aliases seem to get defined anyway. Commenting them out gives no errors in compiling on my MSYS2 environment.

Actually, the proper functions to be used for case-insensitive string comparison seem to be _stricmp and _strnicmp. Would also be an easy change in the code. Outside of dcraw.cc there are only two instances I could find that call either strncasecmp or strcasecmp.