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
Anonymous
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 :)
I have pushed a fix for this:
https://sourceforge.net/p/dfu-util/dfu-util/ci/861753401c3f6d4f2937294b5eb6133b0a583b0c/
This should work fine, thanks!