[go: up one dir, main page]

Menu

#9 broken platform check

0.10
closed
building (1)
2021-09-19
2015-11-05
carstene1ns
No

This platform check in portable.h does not work for (Linux) systems without the ftruncate function:

#ifdef HAVE_FTRUNCATE
# include <unistd.h>
#else
# include <io.h>
#endif /* HAVE_FTRUNCATE */

Autotools will not define it and the preprocessor tries to include the windows-only io header then and of course the build breaks.
I suggest changing it to check for HAVE_UNISTD_H instead, this would be safe (as it will always be defined by autotools on platforms having it, so also safe to include the file then).

Downstream issue: https://github.com/devkitPro/buildscripts/issues/2

Discussion

  • Tormod Volden

    Tormod Volden - 2015-11-06

    Thanks for the report. I think the original reasoning here was that ftruncate() was the only thing requiring unistd.h, and this was not meant for e.g. detecting Windows. Then someone added the Microsoft Visual Support and the io.h as an alternative was added to this same if clause.

    In any case your suggestion sounds fine, including unistd.h if it is available must be safe. Probably a separate ifdef for MSVC should be used for io.h. And ftruncate() is actually not used any longer so this really needs a cleanup.

    BTW, we also support MinGW on Windows, which was the preferred build environment on Windows at least until MSVC support was added, and is more unix-like than MSVC. And it has both io.h and unistd.h :)

     
  • Tormod Volden

    Tormod Volden - 2015-11-06
    • status: open --> accepted
     
  • Tormod Volden

    Tormod Volden - 2016-01-16
    • status: accepted --> closed
    • assigned_to: Tormod Volden
     
  • carstene1ns

    carstene1ns - 2016-01-16

    This should work fine, thanks!

     

Anonymous
Anonymous

Add attachments
Cancel