OMNeT++/OMNEST Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001012OMNeT++command line toolspublic2017-05-04 23:212017-05-04 23:21
Reporterpaolinux 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen 
Platformx86OSWindowsOS Version10
Product Version5.1 
Target VersionFixed in Version 
Summary0001012: nedtool produces the wrong code for auto-generated classes
DescriptionThe following code in a .msg file

class Foo {
      int a = 0;
}

class Bar extends Foo {
      int b = 42;
}

generates the correct code.

However, if I split the declaration in two separate files

#File1.msg

class Foo {
      int a = 0;
}

#File2.msg

cplusplus {{

#include "File1_m.h"

}}

class Foo;

class Bar extends Foo {
      int b = 42;
}

the generated code does not compile any longer.


Steps To Reproduce#DynaPacket.msg

enum DynaPacketType
{
    DYNA_CONN_REQ = 0;
    DYNA_CONN_ACK = 1;
    DYNA_DISC_REQ = 2;
    DYNA_DISC_ACK = 3;
    DYNA_DATA = 4;
};

packet DynaPacket
{
    int srcAddress;
    int destAddress;
    int serverProcId;

    string displayString = "i=msg/package_s,kind";
};

packet DynaDataPacket extends DynaPacket
{
    string payload;
};

class Foo {
      int a = 0;
}

#Foobar.msg

cplusplus {{

#include "DynaPacket_m.h"

}}

class Foo;

class Bar extends Foo {
      int b = 42;
}
Additional InformationThe issue is that if the two classes are declarated in the same file
the following code is generated

Bar::Bar() : ::Foo()
{
    this->b = 42;
}

Instead, if the classes are declared in separate files, the following (buggy) code is generated:

Bar::Bar(const char *name) : ::Foo(name)
{
    this->b = 42;
}

which fails with the following error because Foo does not define a constructor that takes a const char*

Foobar_m.cc: In constructor 'Bar::Bar(const char*)':
Foobar_m.cc:182:40: error: no matching function for call to 'Foo::Foo(const char*&)'
 Bar::Bar(const char *name) : ::Foo(name)
                                        ^
In file included from Foobar_m.h:22:0,
                 from Foobar_m.cc:29:
DynaPacket_m.h:155:5: note: candidate: Foo::Foo(const Foo&)
     Foo(const Foo& other);
     ^~~
DynaPacket_m.h:155:5: note: no known conversion for argument 1 from 'const char*' to 'const Foo&'
DynaPacket_m.h:154:5: note: candidate: Foo::Foo()
     Foo();
     ^~~
DynaPacket_m.h:154:5: note: candidate expects 0 arguments, 1 provided
make: *** [Makefile:105: out/gcc-debug//Foobar_m.o] Error 1
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2017-05-04 23:21 paolinux New Issue


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker