devkitPro / newlib

fork from sourceware git://sourceware.org / newlib-cygwin.git
https://devkitpro.org
GNU General Public License v2.0
22 stars 16 forks source link

devkitA64: no ftruncate when building for the switch #15

Closed glebm closed 5 years ago

glebm commented 5 years ago

I'm using the latest dpkg and cmake

devilutionX/3rdParty/StormLib/src/StormPort.h:279:23: error: 'ftruncate' was not declared in this scope

<unistd.h> is included

glebm commented 5 years ago

Declaring a function in my own code was enough to make it build

// Work around https://github.com/devkitPro/newlib/issues/15
#ifdef __SWITCH__
extern "C" int ftruncate(int, off_t);
#endif
WinterMute commented 5 years ago

You're building with some option that switches off BSD extensions, i.e. -std= or similar. You can re-enable these by using gnu standards or defining appropriate feature test macros.

Try -D_BSD_SOURCE or -D_GNU_SOURCE

This is a devilutionx bug, not a devkitA64 bug.

glebm commented 5 years ago

Thanks! We do indeed compile with -std=c++11. I've now defined -D_POSIX_C_SOURCE=200809L and it compiles. Didn't realize this was a POSIX function.