hyperrealm / libconfig

C/C++ library for processing configuration files
https://hyperrealm.github.io/libconfig/
GNU Lesser General Public License v2.1
1.11k stars 362 forks source link

Windows fixes #208

Closed madebr closed 1 year ago

madebr commented 3 years ago

These patches fixes building libconfig on mingw@Linux in static + shared configuration.

The following warnings are left when building with mingw:

[ 32%] Building C object lib/CMakeFiles/config.dir/libconfig.c.obj
/home/maarten/programming/libconfig/lib/libconfig.c: In function '__config_locale_override':
/home/maarten/programming/libconfig/lib/libconfig.c:100:2: warning: #warning "No way to modify calling thread's locale!" [-Wcpp]
  100 | #warning "No way to modify calling thread's locale!"
      |  ^~~~~~~
/home/maarten/programming/libconfig/lib/libconfig.c: In function '__config_locale_restore':
/home/maarten/programming/libconfig/lib/libconfig.c:121:2: warning: #warning "No way to modify calling thread's locale!" [-Wcpp]
  121 | #warning "No way to modify calling thread's locale!"
      |  ^~~~~~~
[ 91%] Building C object tinytest/CMakeFiles/libtinytest.dir/tinytest.c.obj
/home/maarten/programming/libconfig/tinytest/tinytest.c:30: warning: "F_OK" redefined
   30 | #define F_OK 4  // Windows doesn't have F_OK
      | 
In file included from /home/maarten/programming/libconfig/tinytest/tinytest.c:29:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/io.h:182: note: this is the location of the previous definition
  182 | #define F_OK 0 /* Check for file existence */
      | 

FYI, documentation of _commit (=Windows's counterpart of fsync)

Update: all warnings on mingw are fixed (when building without -Wall. There are some more when adding -Wall -Wextra, but I think these are out of scope for this pr.

madebr commented 3 years ago

I think mingw supports thread local storage of locale: https://github.com/Alexpux/mingw-w64/blob/d0d7f784833bbb0b2d279310ddc6afb52fe47a46/mingw-w64-headers/crt/locale.h#L70-L79