OutpostUniverse / op2ext

Outpost 2 extension module loader
1 stars 0 forks source link

MinGW Warnings #31

Closed DanRStevens closed 5 years ago

DanRStevens commented 5 years ago

I noticed a few warnings from MinGW from my attempts at compiling on Linux.

FileSystemHelper.cpp: In function ‘std::__cxx11::string GetPrivateProfileStdString(std::__cxx11::string, std::__cxx11::string, std::__cxx11::string)’:
FileSystemHelper.cpp:37:7: warning: unused variable ‘returnSize’ [-Wunused-variable]
   int returnSize = GetPrivateProfileString(sectionName.c_str(), key.c_str(), "", buffer, currentBufferSize, filename.c_str());
       ^~~~~~~~~~
ConsoleModuleLoader.cpp: In member function ‘void ConsoleModuleLoader::LoadModule()’:
ConsoleModuleLoader.cpp:65:50: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (GetFileAttributesA(moduleDirectory.c_str()) == -1) {
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
ConsoleModuleLoader.cpp: In member function ‘std::__cxx11::string ConsoleModuleLoader::ParseLoadModCommand(std::vector<std::__cxx11::basic_string<char> >)’:
ConsoleModuleLoader.cpp:143:48: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (GetFileAttributesA(modDirectory.c_str()) == -1) {
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
op2ext.cpp:18:27: warning: ‘StubExt’ initialized and declared ‘extern’
 extern "C" OP2EXT_API int StubExt = 0;
                           ^~~~~~~

I came across a rather strong opinion about the last one, suggesting that warning should be considered a compiler bug. The other ones look quite legitimate though.


For reference: GetPrivateProfileString GetFileAttributesA

The return type of GetFileAttributes is DWORD, which is an alias for unsigned int. The INVALID_FILE_ATTRIBUTES value corresponds to -1, but I assume is casted to a DWORD. We should probably use INVALID_FILE_ATTRIBUTES instead of a numeric literal, both for readability, and to eliminate the warning.

Brett208 commented 5 years ago

Are we ready to close this issue?

-Brett

DanRStevens commented 5 years ago

Indeed. It compiles cleanly with no warnings now. (It just doesn't link, which we're aware of and is documented in the makefile).