Bugzilla – Bug 296
real time scheduler not compiling in MingW
Last modified: 2008-09-07 00:27:27 UTC
ns-3-dev is currently not compiling on MingW due to the real time scheduler merge: [261/506] cxx: src\simulator\wall-clock-synchronizer.cc -> build\debug\src\simul ator\wall-clock-synchronizer_1.o ..\src\simulator\wall-clock-synchronizer.cc:21:19: sched.h: No such file or dire ctory ..\src\simulator\wall-clock-synchronizer.cc: In constructor `ns3::WallClockSynch ronizer::WallClockSynchronizer()': ..\src\simulator\wall-clock-synchronizer.cc:59: error: aggregate `ns3::timespec ts' has incomplete type and cannot be defined ..\src\simulator\wall-clock-synchronizer.cc:60: error: `CLOCK_REALTIME' was not declared in this scope ..\src\simulator\wall-clock-synchronizer.cc:60: error: `clock_getres' was not de clared in this scope ..\src\simulator\wall-clock-synchronizer.cc:60: warning: unused variable 'CLOCK_ REALTIME' ..\src\simulator\wall-clock-synchronizer.cc:60: warning: unused variable 'clock_ getres' ..\src\simulator\wall-clock-synchronizer.cc: In member function `void ns3::WallC lockSynchronizer::NsToTimespec(int64_t, ns3::timespec*)': ..\src\simulator\wall-clock-synchronizer.cc:430: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc:431: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc: In member function `uint64_t ns3::W allClockSynchronizer::TimespecToNs(ns3::timespec*)': ..\src\simulator\wall-clock-synchronizer.cc:445: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc:445: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc: In member function `void ns3::WallC lockSynchronizer::TimespecAdd(ns3::timespec*, ns3::timespec*, ns3::timespec*)': ..\src\simulator\wall-clock-synchronizer.cc:464: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc:464: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc:464: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc:465: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc:465: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc:465: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc:466: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc:468: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.cc:469: error: invalid use of undefined type `struct ns3::timespec' ..\src\simulator\wall-clock-synchronizer.h:178: error: forward declaration of `s truct ns3::timespec' Build failed -> task failed (err #129): [bld://P:\ns-3\ns-3-dev\src\simulator\wall-clock-syn chronizer_1.o] P:\ns-3\ns-3-dev>
same problem in os x powerpc: [262/487] cxx: src/simulator/wall-clock-synchronizer.cc -> build/debug/src/simulator/wall-clock-synchronizer_1.o ../src/simulator/wall-clock-synchronizer.cc: In constructor 'ns3::WallClockSynchronizer::WallClockSynchronizer()': ../src/simulator/wall-clock-synchronizer.cc:60: error: 'CLOCK_REALTIME' was not declared in this scope ../src/simulator/wall-clock-synchronizer.cc:60: error: 'clock_getres' was not declared in this scope Build failed -> task failed (err #129): [bld:///scratch/hg/ns-3-dev/src/simulator/wall-clock-synchronizer_1.o]
same on osX
works now on cygwin, osx but don't have mingw to test on. Does mingw not even know what a struct timespec is?
confirm fix on osX intel.
Created attachment 243 [details] mingw fix I have code ready to commit that leaves out the real time simulator components if the include file "<sched.h>" is not available. OK to commit?
The file <sched.h> (posix process priority and cpu affiniity) really doesn't have anything to do with this, right? The important part is that MinGW apparently doesn't know what a timespec is, right? I'm installing MinGW to see for myself, but if this was the problem, I just checked in some code to not use timespec at all in the case that CLOCK_REALTIME isn't defined. Please check it for me since I cannot yet.
[269/533] cxx: src\simulator\wall-clock-synchronizer.cc -> build\debug\src\simul ator\wall-clock-synchronizer_1.o ..\src\simulator\wall-clock-synchronizer.cc:21:19: sched.h: No such file or dire ctory Build failed -> task failed (err #129): [bld://P:\ns\ns-3-dev\src\simulator\wall-clock-synch ronizer_1.o] About your commit, you can #ifdef out certain methods and the real time scheduler still works? If so, what is the point of having those methods?
OK, two more data points: 1. Removing the #include <sched.h> makes the code compile both in mingw and linux. Apparently sched.h is only used for some code inside #if 0 ... #endif. 2. In wall-clock-synchronizer.h you use #ifdef CLOCK_REALTIME. However, since that header file doesn't include <time.h> won't CLOCK_REALTIME be always undefined (unless by luck whoever includes wall-clock-synchronizer.h had already included time.h first) ? 3. The "#ifdef CLOCK_REALTIME"'ed methods, TimespecToNs and TimespecAdd are protected and currently unused, so I reiterate my suggestion to remove them completely; they are causing portability problems and have no use.
Removed the high resolution clocks since the expected use case did not materialize. Verified builds correctly on MinGW-5.1.4