MantisBT - Zandronum
View Issue Details
0003611Zandronum[All Projects] Bugpublic2019-02-09 18:332019-06-04 20:20
voidpointer 
Torr Samaho 
highmajoralways
resolvedfixed 
DockerAlpine Linux
3.1-beta 
 
0003611: <sys/types.h> include required for upnpnat/upnpnat.cpp
In the zandronum-stable mercurial repository on bitbucket.org, the file "upnpnat/upnpnat.cpp" uses the symbol "u_long", which requires the include "sys/types.h" on linux. Please add this include directive so that code compiles on linux platforms.
No tags attached.
Issue History
2019-02-09 18:33voidpointerNew Issue
2019-04-03 14:09Pol MNote Added: 0020472
2019-05-13 17:20Pol MNote Added: 0020645
2019-05-13 19:13voidpointerNote Added: 0020648
2019-05-13 20:09FilysteaNote Added: 0020650
2019-05-13 20:31voidpointerNote Added: 0020651
2019-05-13 21:08Pol MNote Added: 0020652
2019-05-13 21:10Pol MNote Edited: 0020652bug_revision_view_page.php?bugnote_id=20652#r12576
2019-05-13 21:10Pol MNote Edited: 0020652bug_revision_view_page.php?bugnote_id=20652#r12577
2019-05-19 19:36Torr SamahoNote Added: 0020675
2019-06-04 20:20DuskNote Added: 0020723
2019-06-04 20:20DuskStatusnew => resolved
2019-06-04 20:20DuskResolutionopen => fixed
2019-06-04 20:20DuskAssigned To => Torr Samaho

Notes
(0020472)
Pol M   
2019-04-03 14:09   
I'm gonna take a look :)
(0020645)
Pol M   
2019-05-13 17:20   
So, I've checked the usage of u_long in the file you mentioned, and it seems to be included by the sys/socket.h entry, since that one includes bits/socket.h which includes sys/types.h

I'm not against adding an extra include just for the sake of clarity, but the code does compile ('make' notifies that it is building src/CMakeFiles/zdoom.dir/__/upnpnat/upnpnat.o and does not report any error, resulting in a working zandronum build). Maybe it's an issue in your side? A place for compiling reference is the wiki
(0020648)
voidpointer   
2019-05-13 19:13   
Relying on transitive includes is a bad idea because most of the time, includes provided by other system headers are implementation-defined and not standardized. If there is clear standard documentation that states sys/socket.h must always include (directly or indirectly) sys/types.h, I will file a bug with my respective platform vendor. But I doubt this is the case since POSIX is an interface standard, and interfaces do not include header dependencies.

Note that your code is being compiled on other platforms that you don't test on. By directly including POSIX headers required by files that need them, instead of relying on indirect includes, you make your code more portable.

Thanks for looking into this for me.
(0020650)
Filystea   
2019-05-13 20:09   
That is some dark mix of code.
Unix and windows code for network should be separated. Instead we have what we have.

Minimum is here:
'http://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/types.h.html [^]'

I see no u_long, so this is not something related to posix.
The only mistake that is done in that file is that headers are not in proper order. Which would be like this:

our own libs.

non standard libs

alphabetic order - system libs

alphabetic order - network libs

standard libs.

Alpine Linux is at fault here tbh
(0020651)
voidpointer   
2019-05-13 20:31   
I'll admit I'm not too familiar with POSIX libraries. I did a quick google search prior to my last reply and didn't see anything about indirect includes being standardized.

I think the issue was on Alpine, because I remember initially trying to compile on that platform while trying to build a Docker Image for Zandronum Server. I since have switched to the ubuntu base image, which doesn't have the issue.
(0020652)
Pol M   
2019-05-13 21:08   
(edited on: 2019-05-13 21:10)
Well, since an extra include won't hurt, I'll proceed to make the small change, regardless of how much of the fault is on Alpine's side. here you have your extra line. If you can confirm that it works on your machine, the ticket can be resolved.
you can test it on my repo:

hg clone'https://Pol_M@bitbucket.org/Pol_M/zandronum [^]'
hg update addr-0003611


(0020675)
Torr Samaho   
2019-05-19 19:36   
Thanks, I added your patch.
(0020723)
Dusk   
2019-06-04 20:20   
Looks like this has been fixed by now