0

I am new to vein and omnet++. I followed this tutorial http://veins.car2x.org/tutorial/ everything works up to step 3, for some reason veins 4.7 doesn't build in omnet++ 5 (IDE) and generates the following errors.

veins/modules/utility/TimerManager.cc
In file included from veins/modules/utility/TimerManager.cc:20:
.\veins/modules/utility/TimerManager.h:137:26: error: expected identifier
  enum class StartMode { RELATIVE, ABSOLUTE, IMMEDIATE };
                         ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
                 ^
In file included from veins/modules/utility/TimerManager.cc:20:
.\veins/modules/utility/TimerManager.h:137:36: error: expected identifier
  enum class StartMode { RELATIVE, ABSOLUTE, IMMEDIATE };
                                   ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
                 ^
In file included from veins/modules/utility/TimerManager.cc:20:
.\veins/modules/utility/TimerManager.h:138:24: error: expected identifier
  enum class EndMode { RELATIVE, ABSOLUTE, REPITITION, OPEN };
                       ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
                 ^
In file included from veins/modules/utility/TimerManager.cc:20:
.\veins/modules/utility/TimerManager.h:138:34: error: expected identifier
  enum class EndMode { RELATIVE, ABSOLUTE, REPITITION, OPEN };
                                 ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
                 ^
veins/modules/utility/TimerManager.cc:42:28: error: expected unqualified-id
  start_mode_ = StartMode::RELATIVE;
                           ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
                 ^
veins/modules/utility/TimerManager.cc:48:28: error: expected unqualified-id
  start_mode_ = StartMode::ABSOLUTE;
                           ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
                 ^
veins/modules/utility/TimerManager.cc:54:24: error: expected unqualified-id
  end_mode_ = EndMode::RELATIVE;
                       ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
                 ^
veins/modules/utility/TimerManager.cc:60:24: error: expected unqualified-id
  end_mode_ = EndMode::ABSOLUTE;
                       ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
                 ^
veins/modules/utility/TimerManager.cc:86:19: error: expected unqualified-id
  case StartMode::RELATIVE:
                  ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
                 ^
veins/modules/utility/TimerManager.cc:88:30: error: expected unqualified-id
    start_mode_ = StartMode::ABSOLUTE;
                             ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
                 ^
veins/modules/utility/TimerManager.cc:90:19: error: expected unqualified-id
  case StartMode::ABSOLUTE:
                  ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
                 ^
veins/modules/utility/TimerManager.cc:98:17: error: expected unqualified-id
  case EndMode::RELATIVE:
                ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
                 ^
veins/modules/utility/TimerManager.cc:100:26: error: expected unqualified-id
    end_mode_ = EndMode::ABSOLUTE;
                         ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
                 ^
veins/modules/utility/TimerManager.cc:102:17: error: expected unqualified-id
  case EndMode::ABSOLUTE:
                ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
                 ^
veins/modules/utility/TimerManager.cc:106:26: error: expected unqualified-id
    end_mode_ = EndMode::ABSOLUTE;
                         ^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
                 ^
15 errors generated.
make[1]: *** [Makefile:205: ../out/clang-debug/src/veins/modules/utility/TimerManager.o] Error 1
make[1]: Leaving directory '/c/Users/Abu/src/veins-4.7/src'
make: *** [Makefile:12: all] Error 2

I am also using sumo_win64_0.32.0. I am not sure what causes these errors.

Any help is greatly appreciated.

Julian Heinovski
  • 1,822
  • 3
  • 16
  • 27
Abubakar Saad
  • 202
  • 1
  • 2
  • 13

3 Answers3

2

The issue has been fixed in this pull request and a new minor revision of Veins (i.e. Veins 4.7.1) has been released. Please download the new version to get the fix and also some additional improvements.

Julian Heinovski
  • 1,822
  • 3
  • 16
  • 27
1

I just encountered that error as well and here is what happens:

The compiler cannot resolve the enum class definitions in TimerManager.h as there is a name ambiguity with the macros RELATIVE and ABSOLUTE within wingdi.h

enum class StartMode { RELATIVE, ABSOLUTE, IMMEDIATE };

enum class EndMode { RELATIVE, ABSOLUTE, REPITITION, OPEN };

Quick fix is to rename the occurrences in TimerManager.h and TimerManager.cc to something else. E.g. Replace all occurrences of RELATIVE with RELATIVEINS and ABSOLUTE with ABSOLUTEVEINS etc... (or whatever you like). Worked fine for me with 4.7 and OMNet++ 5.2.1.

Julian Heinovski
  • 1,822
  • 3
  • 16
  • 27
  • 1
    An alternative to editing the code is passing `NOGDI` to the preprocessor, which prevents the conflicting defines to be executed. See https://github.com/sommer/veins/issues/68. – Horstinator Jun 04 '18 at 11:37
1

A patch is required to make Veins 4.7 compile with OMNeT++ 5.3 for Windows. The cleanest way may be something like on https://pastebin.com/ymzqMpEF

- enum class StartMode { RELATIVE, ABSOLUTE, IMMEDIATE }
+ enum class StartMode { relative, absolute, immediate }

that is, renaming the all-uppercase enum class constants to lower case ones (something recommended by many coding styles as well).