Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'locale_t' does not name a type on MinGW #1240

Closed
vedranmiletic opened this issue Jul 20, 2019 · 5 comments
Closed

'locale_t' does not name a type on MinGW #1240

vedranmiletic opened this issue Jul 20, 2019 · 5 comments

Comments

@vedranmiletic
Copy link

vedranmiletic commented Jul 20, 2019

I'm using 64-bit GCC 7.3.0 shipped by Qt open source on 64-bit Windows 10. I get:

>ninja -j1
[1/51] Building CXX object CMakeFiles/fmt.dir/src/posix.cc.obj                                                          FAILED: CMakeFiles/fmt.dir/src/posix.cc.obj
C:\Qt\Tools\mingw730_64\bin\c++.exe  -DFMT_LOCALE -Iinclude -O3 -DNDEBUG   -std=gnu++11 -MD -MT CMakeFiles/fmt.dir/src/posix.cc.obj -MF CMakeFiles\fmt.dir\src\posix.cc.obj.d -o CMakeFiles/fmt.dir/src/posix.cc.obj -c src/posix.cc
In file included from src/posix.cc:13:0:
include/fmt/posix.h:284:3: error: 'locale_t' does not name a type; did you mean '_locale_t'?
   locale_t locale_;
   ^~~~~~~~
   _locale_t
include/fmt/posix.h:290:16: error: 'locale_t' does not name a type; did you mean '_locale_t'?
   using type = locale_t;
                ^~~~~~~~
                _locale_t
include/fmt/posix.h:297:3: error: 'type' does not name a type; did you mean 'wctype'?
   type get() const { return locale_; }
   ^~~~
   wctype
include/fmt/posix.h: In constructor 'fmt::v5::Locale::Locale()':
include/fmt/posix.h:292:14: error: class 'fmt::v5::Locale' does not have any field named 'locale_'
   Locale() : locale_(newlocale(LC_NUMERIC_MASK, "C", nullptr)) {
              ^~~~~~~
include/fmt/posix.h:292:32: error: 'LC_NUMERIC_MASK' was not declared in this scope
   Locale() : locale_(newlocale(LC_NUMERIC_MASK, "C", nullptr)) {
                                ^~~~~~~~~~~~~~~
include/fmt/posix.h:292:32: note: suggested alternative: 'LC_NUMERIC'
   Locale() : locale_(newlocale(LC_NUMERIC_MASK, "C", nullptr)) {
                                ^~~~~~~~~~~~~~~
                                LC_NUMERIC
include/fmt/posix.h:292:22: error: 'newlocale' was not declared in this scope
   Locale() : locale_(newlocale(LC_NUMERIC_MASK, "C", nullptr)) {
                      ^~~~~~~~~
include/fmt/posix.h:292:22: note: suggested alternative: 'setlocale'
   Locale() : locale_(newlocale(LC_NUMERIC_MASK, "C", nullptr)) {
                      ^~~~~~~~~
                      setlocale
include/fmt/posix.h:293:10: error: 'locale_' was not declared in this scope
     if (!locale_) FMT_THROW(system_error(errno, "cannot create locale"));
          ^~~~~~~
include/fmt/posix.h:293:10: note: suggested alternative: 'Locale'
     if (!locale_) FMT_THROW(system_error(errno, "cannot create locale"));
          ^~~~~~~
          Locale
include/fmt/posix.h: In destructor 'fmt::v5::Locale::~Locale()':
include/fmt/posix.h:295:26: error: 'locale_' was not declared in this scope
   ~Locale() { freelocale(locale_); }
                          ^~~~~~~
include/fmt/posix.h:295:26: note: suggested alternative: 'Locale'
   ~Locale() { freelocale(locale_); }
                          ^~~~~~~
                          Locale
include/fmt/posix.h:295:15: error: 'freelocale' was not declared in this scope
   ~Locale() { freelocale(locale_); }
               ^~~~~~~~~~
include/fmt/posix.h:295:15: note: suggested alternative: '_free_locale'
   ~Locale() { freelocale(locale_); }
               ^~~~~~~~~~
               _free_locale
include/fmt/posix.h: In member function 'double fmt::v5::Locale::strtod(const char*&) const':
include/fmt/posix.h:303:41: error: 'locale_' was not declared in this scope
     double result = strtod_l(str, &end, locale_);
                                         ^~~~~~~
include/fmt/posix.h:303:41: note: suggested alternative: 'Locale'
     double result = strtod_l(str, &end, locale_);
                                         ^~~~~~~
                                         Locale
include/fmt/posix.h:303:21: error: 'strtod_l' was not declared in this scope
     double result = strtod_l(str, &end, locale_);
                     ^~~~~~~~
include/fmt/posix.h:303:21: note: suggested alternative: '_strtod_l'
     double result = strtod_l(str, &end, locale_);
                     ^~~~~~~~
                     _strtod_l
ninja: build stopped: subcommand failed.
@vitaut
Copy link
Contributor

vitaut commented Jul 21, 2019

This was fixed in d5d5865#diff-49942e4b3381e0ffc18f880b3f153b0d. Make sure that the FMT_LOCALE macro is not defined.

@vitaut vitaut closed this as completed Jul 21, 2019
@vedranmiletic
Copy link
Author

I remembered that one and thought it might be related. Not sure why CMake doesn't configure it correctly, I am not manually specifying anything. Will investigate.

@vedranmiletic
Copy link
Author

@vitaut it's wrongly detected, that's why I get -DFMT_LOCALE. It's reproducible even on Linux cross-compiler (I'm using MinGW 64 packaged on Fedora, but presumably Debian-based distros would work too):

$ mingw64-cmake -GNinja .
-- CMake version: 3.14.5                                                                                                            
-- The CXX compiler identification is GNU 8.3.0                                                                                     
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ 
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ -- works 
-- Detecting CXX compiler ABI info                                                                                                  
-- Detecting CXX compiler ABI info - done                         
-- Detecting CXX compile features           
-- Detecting CXX compile features - done                                                                                            
-- Version: 5.3.1                                                                                                                   
-- Build type: Release                                            
-- CXX_STANDARD: 11                                                                                                                 
-- Performing Test has_std_11_flag                                
-- Performing Test has_std_11_flag - Success                      
-- Performing Test has_std_0x_flag                                
-- Performing Test has_std_0x_flag - Success                                                                                        
-- Performing Test SUPPORTS_VARIADIC_TEMPLATES                                                                                      
-- Performing Test SUPPORTS_VARIADIC_TEMPLATES - Success          
-- Performing Test SUPPORTS_USER_DEFINED_LITERALS
-- Performing Test SUPPORTS_USER_DEFINED_LITERALS - Success                                                                         
-- Performing Test FMT_HAS_VARIANT     
-- Performing Test FMT_HAS_VARIANT - Success
-- Looking for open        
-- Looking for open - found                                                                                                         
-- Looking for _strtod_l                                                                                                            
-- Looking for _strtod_l - found                                  
-- Looking for C++ include pthread.h                              
-- Looking for C++ include pthread.h - found                                                                                        
-- Looking for pthread_create                                     
-- Looking for pthread_create - found           
-- Found Threads: TRUE                                                                                                              
-- Performing Test HAVE_FNO_DELETE_NULL_POINTER_CHECKS                                                                              
-- Performing Test HAVE_FNO_DELETE_NULL_POINTER_CHECKS - Success
-- FMT_PEDANTIC: OFF                                              
-- Configuring done                                                                                                                 
-- Generating done
CMake Warning:                                                        
  Manually-specified variables were not used by the project:          
                                                                      
    INCLUDE_INSTALL_DIR                                                                                                                      
    SHARE_INSTALL_PREFIX                                                                                                                     
    SYSCONF_INSTALL_DIR                                               
                                                                      
                                                                      
-- Build files have been written to: /home/vedranm/workspace/Development/fmt                                                                 
[vedranm@beg fmt]$ ninja                                              
[1/51] Building CXX object CMakeFiles/fmt.dir/src/posix.cc.obj        
FAILED: CMakeFiles/fmt.dir/src/posix.cc.obj                                                                                                  
/usr/bin/x86_64-w64-mingw32-g++  -DFMT_EXPORT -DFMT_LOCALE -Dfmt_EXPORTS -Iinclude -O2 -DNDEBUG   -std=gnu++11 -MD -MT CMakeFiles/fmt.dir/src/posix.cc.obj -MF CMakeFiles/fmt.dir/src/posix.cc.obj.d -o CMakeFiles/fmt.dir/src/posix.cc.obj -c src/posix.cc
In file included from src/posix.cc:13:                                
include/fmt/posix.h:284:3: error: 'locale_t' does not name a type; did you mean '_locale_t'?                                                 
   locale_t locale_;                                                  
   ^~~~~~~~                                                           
   _locale_t

I'm not very good with CMake macros so I can't provide a patch, but I would be glad to help any other way (e.g. testing).

@vitaut vitaut reopened this Jul 22, 2019
@vitaut
Copy link
Contributor

vitaut commented Jul 26, 2019

Does eac2796 fix the problem?

@vedranmiletic
Copy link
Author

It does. I get a different error now for which I will open a separate issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants