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

Error: invalid use of incomplete type 'class std::__make_unsigned_selector<wchar_t, false, false>' #46

Closed
softwarefailure opened this issue Mar 23, 2018 · 12 comments

Comments

@softwarefailure
Copy link

@softwarefailure softwarefailure commented Mar 23, 2018

I'm trying to compile a C++11 project with gcc 5.4.0 but it doesn't work. I'm getting the error mentioned above. Here is the complete error message:

In file included from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/bits/move.h:57:0,
       from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/bits/stl_pair.h:59,
       from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/bits/stl_algobase.h:64,
       from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/vector:60,
       from ./fpdfsdk/cba_annotiterator.h:10,
       from fpdfsdk/cba_annotiterator.cpp:7:
/dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/type_traits: In instantiation of 'struct std::make_unsigned<wchar_t>':
./core/fxcrt/cfx_string_c_template.h:28:67:   required from 'class CFX_StringCTemplate<wchar_t>'
./core/fxcrt/cfx_string_c_template.h:235:23:   required from here
/dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/type_traits:1757:62: error: invalid use of incomplete type 'class std::__make_unsigned_selector<wchar_t, false, false>'
     { typedef typename __make_unsigned_selector<_Tp>::__type type; };
                           ^
/dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/type_traits:1721:11: note: declaration of 'class std::__make_unsigned_selector<wchar_t, false, false>'
     class __make_unsigned_selector;
      ^
In file included from ./core/fxcrt/fx_string.h:11:0,
       from ./core/fpdfdoc/cpdf_annot.h:15,
       from ./fpdfsdk/cba_annotiterator.h:12,
       from fpdfsdk/cba_annotiterator.cpp:7:
./core/fxcrt/cfx_widestring.h:258:6: error: 'wostream' in namespace 'std' does not name a type
 std::wostream& operator<<(std::wostream& os, const CFX_WideString& str);
      ^
./core/fxcrt/cfx_widestring.h:260:6: error: 'wostream' in namespace 'std' does not name a type
 std::wostream& operator<<(std::wostream& os, const CFX_WideStringC& str);
      ^
In file included from ./core/fxcrt/cfx_bytestring.h:16:0,
       from ./core/fxcrt/fx_string.h:10,
       from ./core/fpdfdoc/cpdf_annot.h:15,
       from ./fpdfsdk/cba_annotiterator.h:12,
       from fpdfsdk/cba_annotiterator.cpp:7:
./core/fxcrt/cfx_string_c_template.h: In instantiation of 'CFX_StringCTemplate<T>::CFX_StringCTemplate(const CharType*, FX_STRSIZE) [with T = wchar_t; CFX_StringCTemplate<T>::CharType = wchar_t; FX_STRSIZE = unsigned int]':
./core/fxcrt/cfx_widestring.h:69:48:   required from here
./core/fxcrt/cfx_string_c_template.h:41:72: error: using invalid field 'CFX_StringCTemplate<T>::m_Ptr'
       : m_Ptr(reinterpret_cast<const UnsignedType*>(ptr)), m_Length(len) {}
                           ^
./core/fxcrt/cfx_string_c_template.h: In instantiation of 'CFX_StringCTemplate<T>::CFX_StringCTemplate(const CFX_StringCTemplate<T>&) [with T = wchar_t]':
./core/fxcrt/cfx_widestring.h:69:48:   required from here
./core/fxcrt/cfx_string_c_template.h:59:11: error: using invalid field 'CFX_StringCTemplate<T>::m_Ptr'
     m_Ptr = src.m_Ptr;
      ^
./core/fxcrt/cfx_string_c_template.h:59:11: error: 'const class CFX_StringCTemplate<wchar_t>' has no member named 'm_Ptr'
./core/fxcrt/cfx_string_c_template.h: In instantiation of 'CFX_StringCTemplate<T>::CFX_StringCTemplate(const CharType*) [with T = wchar_t; CFX_StringCTemplate<T>::CharType = wchar_t]':
./core/fxcrt/cfx_widestring.h:205:35:   required from here
./core/fxcrt/cfx_string_c_template.h:38:42: error: using invalid field 'CFX_StringCTemplate<T>::m_Ptr'
    m_Length(ptr ? FXSYS_len(ptr) : 0) {}
                 ^
./core/fxcrt/cfx_string_c_template.h: In instantiation of 'CFX_StringCTemplate<T>::CFX_StringCTemplate(CFX_StringCTemplate<T>::CharType&) [with T = wchar_t; CFX_StringCTemplate<T>::CharType = wchar_t]':
./core/fxcrt/cfx_widestring.h:212:49:   required from here
./core/fxcrt/cfx_string_c_template.h:54:11: error: using invalid field 'CFX_StringCTemplate<T>::m_Ptr'
     m_Ptr = reinterpret_cast<const UnsignedType*>(&ch);

How can I fix this please? On all other systems (MorphOS, Linux, Mac OS, Windows, Android) the code compiles fine but with the OS4 gcc 5.4.0 I'm getting this error and I haven't got a clue how to fix it. Looks like a compiler issue to me.

I'm invoking gcc like this:

gcc -c -std=c++11 -o test.o test.cpp

@DStastny
Copy link

@DStastny DStastny commented Mar 23, 2018

I saw a comment on amigans.net related to C++11 and comment was this
"Use -std=gnu++11 instead of -std=c++11.

The latter defines STRICT_ANSI which disables newlib functions that are not standard ANSI."

So maybe try changing compile options to use the gnu++11

@softwarefailure
Copy link
Author

@softwarefailure softwarefailure commented Mar 23, 2018

@sba1
Copy link
Owner

@sba1 sba1 commented Mar 24, 2018

AFAIK wide char support is not supported for newlib, so no support for it is included in our gcc. I don't know if it is supported for clib2. If possible, disable the need for wide characters.

@softwarefailure
Copy link
Author

@softwarefailure softwarefailure commented Mar 24, 2018

Unfortunately, wide chars are used all over the project and there is no way to get rid of them. But I don't think that I'd need the complete wide char library for the project to run. On MorphOS it works too and the wide char support is very limited on MorphOS too. I've seen that clib2 has dummies for all wide char functions but I'm not able to get it to compile with clib2 either because the clib2 wide char definitions seem to clash with gcc definitions. Here's the output I get when compiling with -mcrt=clib2.

In file included from ./core/fxcrt/fx_system.h:18:0,
		 from ./core/fxcrt/fx_memory.h:10,
		 from ./core/fxcrt/cfx_maybe_owned.h:12,
		 from ./core/fpdfdoc/cpdf_annot.h:13,
		 from ./fpdfsdk/cba_annotiterator.h:12,
		 from fpdfsdk/cba_annotiterator.cpp:7:
/SDK/clib2/include/wchar.h:77:14: error: conflicting declaration 'typedef long int mbstate_t'
 typedef long mbstate_t;
	      ^
In file included from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/bits/postypes.h:40:0,
		 from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/bits/char_traits.h:40,
		 from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/string:40,
		 from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/stdexcept:39,
		 from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/array:38,
		 from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/tuple:39,
		 from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/bits/stl_map.h:63,
		 from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/map:61,
		 from ./core/fpdfdoc/cpdf_annot.h:10,
		 from ./fpdfsdk/cba_annotiterator.h:12,
		 from fpdfsdk/cba_annotiterator.cpp:7:
/dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/cwchar:58:5: note: previous declaration as 'typedef struct mbstate_t mbstate_t'
   } mbstate_t;
     ^
In file included from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/bits/move.h:57:0,
		 from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/bits/stl_pair.h:59,
		 from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/bits/stl_algobase.h:64,
		 from /dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/vector:60,
		 from ./fpdfsdk/cba_annotiterator.h:10,
		 from fpdfsdk/cba_annotiterator.cpp:7:
/dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/type_traits: In instantiation of 'struct std::make_unsigned<wchar_t>':
./core/fxcrt/cfx_string_c_template.h:28:67:   required from 'class CFX_StringCTemplate<wchar_t>'
./core/fxcrt/cfx_string_c_template.h:235:23:   required from here
/dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/type_traits:1757:62: error: invalid use of incomplete type 'class std::__make_unsigned_selector<wchar_t, false, false>'
     { typedef typename __make_unsigned_selector<_Tp>::__type type; };
							      ^
/dh1/Programmieren/adtools-os4-20170218-372/include/c++/5.4.0/type_traits:1721:11: note: declaration of 'class std::__make_unsigned_selector<wchar_t, false, false>'
     class __make_unsigned_selector;
	   ^
In file included from ./core/fxcrt/fx_string.h:11:0,
		 from ./core/fpdfdoc/cpdf_annot.h:15,
		 from ./fpdfsdk/cba_annotiterator.h:12,
		 from fpdfsdk/cba_annotiterator.cpp:7:
./core/fxcrt/cfx_widestring.h:258:6: error: 'wostream' in namespace 'std' does not name a type
 std::wostream& operator<<(std::wostream& os, const CFX_WideString& str);
      ^
./core/fxcrt/cfx_widestring.h:260:6: error: 'wostream' in namespace 'std' does not name a type
 std::wostream& operator<<(std::wostream& os, const CFX_WideStringC& str);
      ^
In file included from ./core/fxcrt/cfx_bytestring.h:16:0,
		 from ./core/fxcrt/fx_string.h:10,
		 from ./core/fpdfdoc/cpdf_annot.h:15,
		 from ./fpdfsdk/cba_annotiterator.h:12,
		 from fpdfsdk/cba_annotiterator.cpp:7:
./core/fxcrt/cfx_string_c_template.h: In instantiation of 'CFX_StringCTemplate<T>::CFX_StringCTemplate(const CharType*, FX_STRSIZE) [with T = wchar_t; CFX_StringCTemplate<T>::CharType = wchar_t; FX_STRSIZE = unsigned int]':
./core/fxcrt/cfx_widestring.h:69:48:   required from here
./core/fxcrt/cfx_string_c_template.h:41:72: error: using invalid field 'CFX_StringCTemplate<T>::m_Ptr'
       : m_Ptr(reinterpret_cast<const UnsignedType*>(ptr)), m_Length(len) {}
									^
./core/fxcrt/cfx_string_c_template.h: In instantiation of 'CFX_StringCTemplate<T>::CFX_StringCTemplate(const CFX_StringCTemplate<T>&) [with T = wchar_t]':
./core/fxcrt/cfx_widestring.h:69:48:   required from here
./core/fxcrt/cfx_string_c_template.h:59:11: error: using invalid field 'CFX_StringCTemplate<T>::m_Ptr'
     m_Ptr = src.m_Ptr;
	   ^
./core/fxcrt/cfx_string_c_template.h:59:11: error: 'const class CFX_StringCTemplate<wchar_t>' has no member named 'm_Ptr'
./core/fxcrt/cfx_string_c_template.h: In instantiation of 'CFX_StringCTemplate<T>::CFX_StringCTemplate(const CharType*) [with T = wchar_t; CFX_StringCTemplate<T>::CharType = wchar_t]':
./core/fxcrt/cfx_widestring.h:205:35:   required from here
./core/fxcrt/cfx_string_c_template.h:38:42: error: using invalid field 'CFX_StringCTemplate<T>::m_Ptr'
	 m_Length(ptr ? FXSYS_len(ptr) : 0) {}
					  ^
./core/fxcrt/cfx_string_c_template.h: In instantiation of 'CFX_StringCTemplate<T>::CFX_StringCTemplate(CFX_StringCTemplate<T>::CharType&) [with T = wchar_t; CFX_StringCTemplate<T>::CharType = wchar_t]':
./core/fxcrt/cfx_widestring.h:212:49:   required from here
./core/fxcrt/cfx_string_c_template.h:54:11: error: using invalid field 'CFX_StringCTemplate<T>::m_Ptr'
     m_Ptr = reinterpret_cast<const UnsignedType*>(&ch);

As you can see, the clib2 definition of mbstate_t clashes with gcc's definition of mbstate_t. Can't this be fixed so that I'm at least able to compile the project properly - even if all wide char functions are just NOPs?

@sba1
Copy link
Owner

@sba1 sba1 commented Mar 24, 2018

Can you please create a small test example, ideally as a pull request with a file in the test folder? I'll then see what I can do for you.

@softwarefailure
Copy link
Author

@softwarefailure softwarefailure commented Mar 25, 2018

@broadblues
Copy link

@broadblues broadblues commented Mar 25, 2018

[quote]
Can't this be fixed so that I'm at least able to compile the project properly - even if all wide char functions are just NOPs?
[/quote]

You could edit the clib2 header, since long and long int are essentially the same, that might get things compiling. Not perfect if it's something you need to distribute as src code, but if internal then not a problem.

@softwarefailure
Copy link
Author

@softwarefailure softwarefailure commented Mar 25, 2018

sba1 added a commit that referenced this issue Mar 25, 2018
@sba1
Copy link
Owner

@sba1 sba1 commented Mar 25, 2018

There are multiple problems I think. I added a simple test for at least one of them.

@sba1
Copy link
Owner

@sba1 sba1 commented Mar 25, 2018

The configure step for the clib2-based libstdc++ build doesn't recognize the presence of mbstate_t properly, because wchar.h of clib2 contains following line

extern size_t mbrtowc_l(wchar_t *restrict pwc, const char *restrict s, size_t n, mbstate_t *restrict ps, locale_t loc);

and locale_t is not defined in the context. So far, I have only checked the SDK-supplied clib2 that is used for the adtools build as well.

@sba1
Copy link
Owner

@sba1 sba1 commented Mar 25, 2018

The problem was fixed in clib2 by commit adtools/clib2@309bbd8 which happened after the latest release available so far.

@sba1
Copy link
Owner

@sba1 sba1 commented Mar 28, 2018

BTW, this is a duplicate of #42.

@sba1 sba1 closed this Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants