OMNeT++/OMNEST Bug Tracker - OMNeT++
View Issue Details
0000136OMNeT++IDE / C++ developmentpublic2010-02-03 13:372010-05-09 22:19
0000136: automatic message/object generation fails on "using" in cpluplus section
bug report is actually for version 4.1b


using namespace std;

in a message definition file let the code generation skip the cplusplus section.

example (from inetmanet):

cplusplus {{
#include "DYMO_PacketBBMessage_m.h"
#include "DYMO_AddressBlock.h"

#include <vector>
#include <sys/types.h>

using namespace std;

typedef vector<DYMO_AddressBlock> VectorOfDYMOAddressBlocks;

#include "InspectorHelpers.h"


class noncobject VectorOfDYMOAddressBlocks;

class DYMO_PacketBBMessage;

struct DYMO_AddressBlock;

message DYMO_RERR extends DYMO_PacketBBMessage
    VectorOfDYMOAddressBlocks unreachableNodes;

No tags attached.
? opp_msgc (84,746) 2010-03-08 17:47
? opp_msgc_2 (84,747) 2010-03-08 18:21
Issue History
2010-02-03 13:37danielNew Issue
2010-03-08 17:47drewhkFile Added: opp_msgc
2010-03-08 17:49drewhkNote Added: 0000213
2010-03-08 18:18drewhkNote Added: 0000214
2010-03-08 18:21drewhkFile Added: opp_msgc_2
2010-05-09 22:19andrasNote Added: 0000293
2010-05-09 22:19andrasStatusnew => resolved
2010-05-09 22:19andrasFixed in Version => 4.1rc1
2010-05-09 22:19andrasResolutionopen => fixed
2010-05-09 22:19andrasAssigned To => andras

2010-03-08 17:49   
Attached a workaround. The problem is that the opp_msgc uses a regex to find namespace keyword in the msg file

$NAMESPACE_DECL = '\bnamespace\s+([A-Za-z0-9_:]+)\s*;'

but this regex matches the "using namespace" directive in the cplusplus{{}} block.
As a workaround I changed the line to:

$NAMESPACE_DECL = '^namespace\s+([A-Za-z0-9_:]+)\s*;'

so it matches the "namespace" token on line starts.

2010-03-08 18:18   
Ooops. Of course that line should be

$NAMESPACE_DECL = '\nnamespace\s+([A-Za-z0-9_:]+)\s*;'

instead. Uploading fixed version.
2010-05-09 22:19   
Fixed. Solution is to temporarily remove cplusplus blocks before looking for the namespace line in the source, and put them back afterwards.

The proposed patch, while appreciated, was not so good because both C++ and msg files are free-form and there is no requirement that in msg a namespace decl has to begin at the beginning of the line, and also in C++ one can write "using<newline>namespace x;" -- both cases would make the patch to fail.