g++ & _XOPEN_SOURCE

David Schultz das at FreeBSD.ORG
Mon Jan 31 07:12:07 PST 2005


On Tue, Feb 01, 2005, Kevin Dorne wrote:
> I have been working on getting lurker (http://lurker.sourceforge.net) 
> to compile on FreeBSD.  I managed to do it by removing all #define 
> _XOPEN_SOURCE 500 from the source files, but the application's author 
> suggested that such behaviour signified a major bug in libc/c++.
> 
> For example, compiling just this file
> 
> #define _XOPEN_SOURCE 500
> #include <string>
> 
> Gave me this error:
> In file included from /usr/include/c++/3.4/bits/postypes.h:46,
>                  from /usr/include/c++/3.4/iosfwd:50,
>                  from /usr/include/c++/3.4/bits/stl_algobase.h:70,
>                  from /usr/include/c++/3.4/bits/char_traits.h:46,
>                  from /usr/include/c++/3.4/string:47,
>                  from xx.cpp:2:
> /usr/include/c++/3.4/cwchar:166: error: `::vfwscanf' has not been 
> declared
> /usr/include/c++/3.4/cwchar:170: error: `::vswscanf' has not been 
> declared
> /usr/include/c++/3.4/cwchar:174: error: `::vwscanf' has not been 
> declared
> /usr/include/c++/3.4/cwchar:191: error: `::wcstof' has not been declared
> 
> Is this a bug or a feature?

Setting _XOPEN_SOURCE to 500 instructs libc that you want *only*
the routines specified in SUSv2, so more recent ones like
vfwscanf() (from C99) will not be declared.  However, libstdc++
sometimes assumes that the default symbols are available, and
hence the error.  Perhaps you should report this as a GNU
libstdc++ bug.

A while ago, Loren was working on fixing this on the libstdc++
end, so I'm Cc'ing him on this.  Loren, is there something we
could define in wchar.h that would make this easier to fix?
Presently, we have:

#if __ISO_C_VISIBLE >= 1999
int	vfwscanf(struct __sFILE * __restrict, const wchar_t * __restrict,
	    __va_list);
[...]
#endif	/* __ISO_C_VISIBLE >= 1999 */


More information about the freebsd-standards mailing list