Segmentation fault

26 views
Skip to first unread message

Anjana Prabhakar

unread,
Sep 9, 2017, 12:23:09 PM9/9/17
to omn...@googlegroups.com
Hi All..
I am getting a segmentation fault on calling the inbuilt function
 const char *MatchableObject::getAsString() const
 The code is as follows :
bool MatchExpression::matches(const Matchable *object)
{
........
const char *attr;
attr=object->getAsString();
........
}

Please help.

baukran

unread,
Sep 9, 2017, 12:28:51 PM9/9/17
to OMNeT++ Users
You need to allocate a new Matchable object on the heap first before you can you use (e.g. call getAsString()) it.

I don't know what MatchableObject is, but something like:
Matchable *object = new Matchable();

Maybe you should read about the basics of C++, including how to create and deal with objects. 

Am Samstag, 9. September 2017 18:23:09 UTC+2 schrieb Anjana Prabhakar:
Hi All..
I am getting a segmentation fault on calling the inbuilt function
 const char *MatchableObject::getAsString() const
 as :
const Matchable *object;
const char *attr;
attr=object->getAsString();

Please help.

Anjana Prabhakar

unread,
Sep 11, 2017, 1:36:59 AM9/11/17
to OMNeT++ Users
Sorry for the confusion. Have edited the question.

Alfonso Ariza Quintana

unread,
Sep 11, 2017, 5:41:33 AM9/11/17
to omn...@googlegroups.com

const Matchable *object;

attr=object->getAsString();

 

object pointer doesn’t have a valid object.

 

De: omn...@googlegroups.com [mailto:omn...@googlegroups.com] En nombre de Anjana Prabhakar
Enviado el: sábado, 09 de septiembre de 2017 18:23
Para: OMNeT++ Users <omn...@googlegroups.com>
Asunto: [Omnetpp-l] Segmentation fault

 

Hi All..

I am getting a segmentation fault on calling the inbuilt function

 const char *MatchableObject::getAsString() const

 as :

const Matchable *object;

const char *attr;

attr=object->getAsString();

 

Please help.

 

--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

Anjana Prabhakar

unread,
Sep 11, 2017, 5:44:41 AM9/11/17
to OMNeT++ Users
Sorry for the ambiguity. I have modified the question.
Reply all
Reply to author
Forward
0 new messages