kangsouth
kangsouth

Reputation: 73

OMNeT++ error: could not be resolved

I am new to OMNeT++ and I am learning OMNeT++ now.I want to run a tictoc simulation according to the tutorial .First I couldn't create a project,it said that Error:CoreException.Some people told me to change the text file encoding into UTF-8.Then the problem was solved.But when I added a new C++ source file,another problem appeared: could not be resolved.

#include <string.h>
#include <omnetpp.h>
class Txc1 : public cSimpleModule
{
   protected:

   virtual void initialize();
   virtual void handleMessage(cMessage *msg);
};

Define_Module(Txc1);

void Txc1::initialize()
{
    // Am I Tic or Toc?
    if (strcmp("tic", getName()) == 0)
    {

        cMessage *msg = new cMessage("tictocMsg");
        send(msg, "out");
    }
}

void Txc1::handleMessage(cMessage *msg)
{

    send(msg, "out");
}

cSimpleModule,Define_Module,cMessage...all these things could not be resolved.

But incredibly,I could build the project.And when I clicked the Menu Run->Run As OMNeT++ simulation,it ran normally.So is it true that chaning the text file encoding caused this problem?How can I solve it?

Upvotes: 1

Views: 1498

Answers (1)

Attila
Attila

Reputation: 1493

You need to add

using namespace omnetpp;

after the headers are included if you wish to use the classes in it (cSimpleModule, cMessage) without the omnetpp:: prefix.

Creating your own simple modules requires some proficiency in C++. Of course you can learn by doing, but this error was not specific to OMNeT++, this is a general C++ programming mistake.

Upvotes: 1

Related Questions