c++linuxslackware

Slackware 15.0 "Hello World" C++ program can't be compiled with GNU compiler


so I'm using Slackware 15.0 after updates, GCC 11.2 and after I couldn't compile my more complex program I just tried to compile simple "Hello World" program:

#include <iostream>

int main() {
    std::cout << "Hello World";
}

..but surprisingly I'm getting tons of errors like:

/usr/local/include/wctype.h:178:21: error: expected initializer before 'wctrans'
  178 |   wctrans_t __cdecl wctrans(const char *);
      |                     ^~~~~~~
/usr/local/include/wctype.h:179:20: error: expected initializer before 'wctype'
  179 |   wctype_t __cdecl wctype(const char *);
      |                    ^~~~~~
In file included from /usr/include/c++/11.2.0/bits/locale_facets.h:39,
                 from /usr/include/c++/11.2.0/bits/basic_ios.h:37,
                 from /usr/include/c++/11.2.0/ios:44,
                 from /usr/include/c++/11.2.0/ostream:38,
                 from /usr/include/c++/11.2.0/iostream:39,
                 from test.cpp:1:
/usr/include/c++/11.2.0/cwctype:86:11: error: 'iswalnum' has not been declared in '::'
   86 |   using ::iswalnum;
      |           ^~~~~~~~
/usr/include/c++/11.2.0/cwctype:87:11: error: 'iswalpha' has not been declared in '::'
   87 |   using ::iswalpha;

In file included from /usr/include/c++/11.2.0/bits/locale_facets.h:2682,
                 from /usr/include/c++/11.2.0/bits/basic_ios.h:37,
                 from /usr/include/c++/11.2.0/ios:44,
                 from /usr/include/c++/11.2.0/ostream:38,
                 from /usr/include/c++/11.2.0/iostream:39,
                 from test.cpp:1:
/usr/include/c++/11.2.0/bits/locale_facets.tcc: In member function 'virtual _InIter std::num_get<_CharT, _InIter>::do_get(std::num_get<_CharT, _InIter>::iter_type, std::num_get<_CharT, _InIter>::iter_type, std::ios_base&, std::ios_base::iostate&, float&) const':
/usr/include/c++/11.2.0/bits/locale_facets.tcc:697:55: error: there are no arguments to '_S_get_c_locale' that depend on a template parameter, so a declaration of '_S_get_c_locale' must be available [-fpermissive]
  697 |       std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
      |                                                       ^~~~~~~~~~~~~~~
/usr/include/c++/11.2.0/bits/locale_facets.tcc: In member function 'virtual _InIter std::num_get<_CharT, _InIter>::do_get(std::num_get<_CharT, _InIter>::iter_type, std::num_get<_CharT, _InIter>::iter_type, std::ios_base&, std::ios_base::iostate&, double&) const':
/usr/include/c++/11.2.0/bits/locale_facets.tcc:712:55: error: there are no arguments to '_S_get_c_locale' that depend on a template parameter, so a declaration of '_S_get_c_locale' must be available [-fpermissive]
  712 |       std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());

/usr/include/c++/11.2.0/bits/locale_facets.tcc:1038:45: error: there are no arguments to '_S_get_c_locale' that depend on a template parameter, so a declaration of '_S_get_c_locale' must be available [-fpermissive]
 1038 |               __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,

Can you advise where to start to solve this?


Solution

  • /usr/local/include/wctype.h looks like it's a windows header, __cdecl is a Microsoft function modifier and isn't recognised by GCC, it then assumes that __cdecl is a variable name leading it to expect an initialiser for that variable as the next token rather than a function name.

    As the include is in /usr/local/ it's likely not something installed by a system package, something else you've installed will have put that header there, uninstalling whatever that is, is likely the best solution. Otherwise deleting any windows headers from that folder manually would be the other option but make sure you don't delete anything important.