On Tue, Mar 09, 2021 at 01:41:25AM -0700, Anthony J. Bentley wrote:
> Hi,
> 
> When updating a port I came across a weird compile error within iostream
> if _POSIX_C_SOURCE is set. 200112 and 200809 both error out in different
> ways.

This looks like the same problem as
https://marc.info/?l=openbsd-bugs&m=157758838031146&w=2

> 
> $ cat foo.cc
> #include <iostream>
> int main() {}
> $ clang++ -D_POSIX_C_SOURCE=200112 foo.cc
> In file included from foo.cc:1:
> In file included from /usr/include/c++/v1/iostream:37:
> In file included from /usr/include/c++/v1/ios:215:
> In file included from /usr/include/c++/v1/__locale:32:
> In file included from /usr/include/c++/v1/support/newlib/xlocale.h:25:
> /usr/include/c++/v1/support/xlocale/__strtonum_fallback.h:23:64: error: 
> unknown
>       type name 'locale_t'
>                                                 char **endptr, locale_t) {
>                                                                ^
> /usr/include/c++/v1/support/xlocale/__strtonum_fallback.h:28:65: error: 
> unknown
>       type name 'locale_t'
>                                                  char **endptr, locale_t) {
>                                                                 ^
> /usr/include/c++/v1/support/xlocale/__strtonum_fallback.h:33:71: error: 
> unknown
>       type name 'locale_t'
>   ...char **endptr, locale_t) {
>                     ^
> /usr/include/c++/v1/support/xlocale/__strtonum_fallback.h:38:54: error: 
> unknown
>       type name 'locale_t'
> strtoll_l(const char *nptr, char **endptr, int base, locale_t) {
>                                                      ^
> /usr/include/c++/v1/support/xlocale/__strtonum_fallback.h:43:55: error: 
> unknown
>       type name 'locale_t'
> strtoull_l(const char *nptr, char **endptr, int base, locale_t) {
>                                                       ^
> /usr/include/c++/v1/support/xlocale/__strtonum_fallback.h:48:60: error: 
> unknown
>       type name 'locale_t'
> wcstoll_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) {
>                                                            ^
> /usr/include/c++/v1/support/xlocale/__strtonum_fallback.h:53:61: error: 
> unknown
>       type name 'locale_t'
> wcstoull_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) {
>                                                             ^
> /usr/include/c++/v1/support/xlocale/__strtonum_fallback.h:58:74: error: 
> unknown
>       type name 'locale_t'
>   ...wchar_t **endptr, locale_t) {
>                        ^
> In file included from foo.cc:1:
> In file included from /usr/include/c++/v1/iostream:37:
> In file included from /usr/include/c++/v1/ios:215:
> /usr/include/c++/v1/__locale:54:25: error: unknown type name 'locale_t'
>   __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {}
>                         ^
> /usr/include/c++/v1/__locale:62:3: error: unknown type name 'locale_t'
>   locale_t __old_loc_;
>   ^
> /usr/include/c++/v1/__locale:132:20: error: use of undeclared identifier
>       'LC_COLLATE_MASK'
>         collate  = LC_COLLATE_MASK,
>                    ^
> /usr/include/c++/v1/__locale:133:20: error: use of undeclared identifier
>       'LC_CTYPE_MASK'
>         ctype    = LC_CTYPE_MASK,
>                    ^
> /usr/include/c++/v1/__locale:134:20: error: use of undeclared identifier
>       'LC_MONETARY_MASK'
>         monetary = LC_MONETARY_MASK,
>                    ^
> /usr/include/c++/v1/__locale:135:20: error: use of undeclared identifier
>       'LC_NUMERIC_MASK'
>         numeric  = LC_NUMERIC_MASK,
>                    ^
> /usr/include/c++/v1/__locale:136:20: error: use of undeclared identifier
>       'LC_TIME_MASK'
>         time     = LC_TIME_MASK,
>                    ^
> /usr/include/c++/v1/__locale:137:20: error: use of undeclared identifier
>       'LC_MESSAGES_MASK'
>         messages = LC_MESSAGES_MASK,
>                    ^
> /usr/include/c++/v1/__locale:349:5: error: unknown type name 'locale_t'; did 
> you
>       mean 'locale'?
>     locale_t __l;
>     ^
> /usr/include/c++/v1/__locale:121:24: note: 'locale' declared here
> class _LIBCPP_TYPE_VIS locale
>                        ^
> /usr/include/c++/v1/__locale:368:5: error: unknown type name 'locale_t'; did 
> you
>       mean 'locale'?
>     locale_t __l;
>     ^
> /usr/include/c++/v1/__locale:121:24: note: 'locale' declared here
> class _LIBCPP_TYPE_VIS locale
>                        ^
> /usr/include/c++/v1/__locale:740:5: error: unknown type name 'locale_t'; did 
> you
>       mean 'locale'?
>     locale_t __l;
>     ^
> /usr/include/c++/v1/__locale:121:24: note: 'locale' declared here
> class _LIBCPP_TYPE_VIS locale
>                        ^
> fatal error: too many errors emitted, stopping now [-ferror-limit=]
> 20 errors generated.
> 
> $ clang++ -D_POSIX_C_SOURCE=200809 foo.cc 
> In file included from foo.cc:1:
> In file included from /usr/include/c++/v1/iostream:39:
> In file included from /usr/include/c++/v1/istream:163:
> In file included from /usr/include/c++/v1/ostream:140:
> In file included from /usr/include/c++/v1/locale:207:
> /usr/include/c++/v1/__bsd_locale_fallbacks.h:122:17: error: use of undeclared
>       identifier 'vasprintf'; did you mean 'vsprintf'?
>     int __res = vasprintf(__s, __format, __va);
>                 ^
> /usr/include/c++/v1/cstdio:124:9: note: 'vsprintf' declared here
> using ::vsprintf;
>         ^
> In file included from foo.cc:1:
> In file included from /usr/include/c++/v1/iostream:39:
> In file included from /usr/include/c++/v1/istream:163:
> In file included from /usr/include/c++/v1/ostream:140:
> In file included from /usr/include/c++/v1/locale:207:
> /usr/include/c++/v1/__bsd_locale_fallbacks.h:122:27: error: cannot initialize 
> a
>       parameter of type 'char *' with an lvalue of type 'char **'
>     int __res = vasprintf(__s, __format, __va);
>                           ^~~
> /usr/include/stdio.h:269:21: note: passing argument to parameter here
> int      vsprintf(char *, const char *, __va_list);
>                         ^
> 2 errors generated.
> 
> 

Reply via email to