Do we have a C++11 compatible compiler for OS4?

This forum is for general developer support questions.
Post Reply
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

Do we have a C++11 compatible compiler for OS4?

Post by softwarefailure »

AFAICS the latest SDK comes with gcc 4.2.4 which doesn't support C++11. Is there anything newer available? I think we'd need at least gcc 4.8 for proper C++11 support.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Do we have a C++11 compatible compiler for OS4?

Post by broadblues »

The adtools repository contains the latest GCC 5.4

https://github.com/sba1/adtools

There is a semi official set of builds here:

https://dl.bintray.com/sba1/adtools-native/

be careful about installing the coreutils in those packages, as of 2017 they were incorrectly built against newlib and so broken.

I notice there is a now 2018 archive, not investigated that yet.

C++ 11 is generarlly supported but some parts such as threads may not be. Also dynamic linking can be problematic due to libstdc++ name clashes with the existing OS version. Static is fine though.
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

Re: Do we have a C++11 compatible compiler for OS4?

Post by softwarefailure »

Thanks. I don't need threads or dynamic linking so it should be fine.

Unfortunately, it doesn't work. I tried both the oldest (18/02/17) and latest (29/01/18) of the packages from your link but they both don't work.

Here is what I get:

Code: Select all

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);
This doesn't look like it is anything that I could fix. It looks like something in the compiler setup is broken, doesn't it?

I compile like this:

Code: Select all

gcc -c -std=c++11 -o test.o test.cpp
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Do we have a C++11 compatible compiler for OS4?

Post by broadblues »

I'm not a C++ expert but I think it's to do with strict interpretations of standards. Using --std=gnu++11 instead gets you what you need.

See this thread:

http://www.amigans.net/modules/xforum/v ... 2&forum=25
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

Re: Do we have a C++11 compatible compiler for OS4?

Post by softwarefailure »

No, it's a wide char issue. Seems like the OS4 gcc doesn't support wide chars at all. Let's hope they can fix it.

See here:
https://github.com/sba1/adtools/issues/46
Post Reply