OMNeT++/OMNEST Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000832OMNeT++IDE / C++ developmentpublic2015-08-12 19:092017-02-13 12:30
Assigned Torhornig 
PlatformWindows and LinuxOSOS Version
Product Version4.6 
Target VersionFixed in Version5.1pre3 
Summary0000832: Adding -pedantic compiler option triggers warnings in OMNeT++ headers
DescriptionI wanted to use the compiler option -pedantic in one of my projects.
But compiling the project with this options overflows to console window with lots of warnings generated by some OMNeT++ headers.

All of these warnings are of the same type (warning: extra ‘;’) and are triggered by only 2 places in the code:

Place 1: nedsupport.h

This file contains the definition of the namespace 'NEDSupport', which ends at the end of the file, and is terminated with a semicolon. This semicolon is not necessary, triggers a warning, and can be safely removed.

Place 2: onstartup.h

This is more difficult. I can describe why the warning triggers, but I don't know how to fix it.

Suppose you have a message file name MyMessages.msg with a message type called MyMessage. Compiling this file creates a C++ file called

This file will contain the lines

These macros are defined in 'regmacros.h' and both contain as their last statement the macro EXECUTE_ON_STARTUP which is defined in 'onstartup.h'.

The code in EXECUTE_ON_STARTUP defines a namespace which is again followed by a semicolon. Again, this semicolon is not necessary and can be removed.

However, this time this is not enough: When the Register_Class macro is expanded, the semicolon after Register_Class in the original C++ File ( will follow right after the namespace definition, where it triggers the same warning.

I don't know how to fix this. As a very dirty workaround, I have added the following statement at the end of EXECUTE_ON_STARTUP:
   struct MAKE_UNIQUE_WITHIN_FILE(dirty_workaround_for_compiler_warning)

This gets rid of the warning, and I can compile my code with -pedantic without a single warning. However, the intention of adding -pedantic is to write clean code, so adding dirty hacks is probably not a good way to shut down a warning :)

It hasn't triggered a warning with my code, but the macro EXECUTE_ON_SHUTDOWN has the same structure as EXECUTE_ON_STARTUP, so I guess changes for one should also be applied to the other.
Additional InformationTo add the compiler option -pedantic, I added the following text in project settings->OMNeT++->Makemake->Options->Custom->Makefrag:

CXXFLAGS += -pedantic
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
rhornig (administrator)
2017-02-13 12:30

Pragmas were added to mute expected warnings in OMNeT++ code.

- Issue History
Date Modified Username Field Change
2015-08-12 19:09 woife New Issue
2015-10-12 09:28 ammmar1988 Issue cloned: 0000842
2017-02-13 12:30 rhornig Note Added: 0001316
2017-02-13 12:30 rhornig Status new => resolved
2017-02-13 12:30 rhornig Fixed in Version => 5.1pre3
2017-02-13 12:30 rhornig Resolution open => fixed
2017-02-13 12:30 rhornig Assigned To => rhornig

Copyright © 2000 - 2022 MantisBT Team
Powered by Mantis Bugtracker