OMNeT++/OMNEST Bug Tracker - OMNeT++
View Issue Details
0000984OMNeT++simulation kernelpublic2017-01-11 20:222017-02-01 15:27
0000984: error "#include <platdep/sockets.h> must precede <omnetpp.h> (and <platdep/timeutil.h> if present)" not possible in msg-files
I get an error with OMNeT++ 5.1preview2:
error "#include <platdep/sockets.h> must precede <omnetpp.h> (and <platdep/timeutil.h> if present)"

Situation is the following:
I have a message file:
packet CTFrame extends EthernetIIFrame

therefore the message file contains:
cplusplus {{
    #include "inet/linklayer/ethernet/EtherFrame_m.h"

In the generated code i have #include <omnetpp.h> in top and below:
// cplusplus {{
    #include "inet/linklayer/ethernet/EtherFrame_m.h"
// }}

But EtherFrame_m.h includes Ethernet.h that itself includes INETDefs.h that includes precompiled.h that includes sockets.h that defines the error.

I have no idea how to fix that, because the code is generated by the msg compiler. I cannot change the order of the includes!
No tags attached.
Issue History
2017-01-11 20:22tillNew Issue
2017-01-27 14:25rhornigNote Added: 0001276
2017-02-01 11:10andrasNote Added: 0001277
2017-02-01 11:10andrasStatusnew => resolved
2017-02-01 11:10andrasFixed in Version => 5.1pre3
2017-02-01 11:10andrasResolutionopen => fixed
2017-02-01 11:10andrasAssigned To => andras

2017-01-27 14:25   
This is indeed bad. The proper solution will be:
- remove the ordering constraint between omnetpp.h and platdep/sockets.h
- remove platdep/sockets.h from precompiled.h in INET

This solution will work only with OMNET 5.1 pre3+ and INET 3.5
2017-02-01 11:10   
Solution: in platdep/timeutil.h, don't define timeval ourself, just pull in <winsock2.h> (forget the obsolete <winsock.h>, it should never be used). In platdep/sockets.h, also include <winsock2.h> unconditionally, and remove the #error directive.