News:

Simutrans Chat Room
Where cool people of Simutrans can meet up.

Compile error when compiling with -std=c++03

Started by ceeac, September 04, 2020, 05:43:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ceeac


obj/baum.cc:321:87: error: unknown type name 'intptr_t'; did you mean '__intptr_t'?
        sint16 random = (sint16)( get_pos().x + get_pos().y + get_pos().z + slope + (sint16)(intptr_t)this );
                                                                                             ^~~~~~~~
                                                                                             __intptr_t
/usr/include/x86_64-linux-gnu/bits/types.h:206:25: note: '__intptr_t' declared here
__STD_TYPE __SWORD_TYPE __intptr_t;
                        ^
1 error generated.

intptr_t requires C++11. Is C++11 now allowed/required?

prissi

But MSCV does no know __intptr_t, only intptr_t. Actually, I had to add this otherwise GCC did not compile, even though the code was correct and MSVC 2015 did not complain, while it not supports C++11 fully.

So honestly Simutrans goes by what compiles on most systems.

intptr_t requires C++11.

Well, it just requires an include file like <stdint.h> which is around since 1998, http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.dinkum_en_c99%2Fstdint.html

TurfIt

From config.template:

# The following useful conditional compilation flags exist
#
# Needed to compile:
# NO_INTPTR_T: must be set if intptr_t is not available

However this is only used in ptrhashtable_tpl. Uses of intptr_t have appeared in baum.cc, schedule_gui.cc, and searchfolder.cc breaking this functionality.

As for <stdint.h>:

intptr_t uintptr_t Integer type capable of holding a value converted from a void pointer and then be converted back to that type with a value that compares equal to the original pointer.
Optional: These typedefs may not be defined in some library implementations.*


prissi

Thank you, I moved this code to simtypes.h in r9212

Dwachs

These two commits do not compile. I tried to repair this. I do not know whether this solves the original bug report.
Parsley, sage, rosemary, and maggikraut.

Ters

Quote from: prissi on September 04, 2020, 06:10:05 AMWell, it just requires an include file like <stdint.h> which is around since 1998
Since stdint.h is part of C99, which in turn was not part of C++ until C++11, I think it might be legal for a compiler to disable that file somehow unless either pure C99 or higher, or C++11 or higher, is selected. Furthermore, it is not mandatory, but I guess that is just a provision for architectures where pointers behave very strangely.