0

I'm starting some work into manual programming of nodes in OPNET however I am having a few troubles. I'm getting some information from packets and storing them in variables and want to output this to the simulation console. When I add the line puts(bcast_info) I get the following error.

C:/Users/Andrew/op_models/traffic_source.pr.c(74) : warning C4047:
'function' : 'const char *' differs in levels of indirection from
'Objid' C:/Users/Andrew/op_models/traffic_source.pr.c(74) : warning
C4024: 'puts' : different types for formal and actual parameter 1

Prior to adding the line mentioned above, the simulation worked perfectly and I got the basic text output. This is my code so far.

 static void route_pk(void)
    {
    Packet * pkptr;
    Objid bcast_info;
    FIN(route_pk());
    pkptr = op_pk_get(op_intrpt_strm ());
    bcast_info = op_pk_bcast_get (pkptr);
    printf ("Hello! \n");
    puts("Hello from puts");
    puts(bcast_info);
    op_pk_send (pkptr, 1);
    FOUT;
    }

I appreciate that OPNET is a variation on the C language with some of its own methods etc but any help on what the errors actually mean and potential fixes would be much appreciated. Please be aware that I have never worked with C / C++ or this OPNET language before.

simonc
  • 41,632
  • 12
  • 85
  • 103
Reidacus
  • 103
  • 2
  • 13
  • What is `Objid`? Debug your program until you have a minimal testcase. – Lightness Races in Orbit Jul 07 '14 at 16:34
  • puts expects a const char *. Instead you supply an Objid. We dont know what one of those is – pm100 Jul 07 '14 at 16:44
  • Well according to OPNET its an object identifier to return the ID of a specified object. According to their database of documentation " numeric object ID or hierarchical name of the object-of-interest" and the following example is given. objid pksw2.node0 object ID: 9 – Reidacus Jul 07 '14 at 16:51
  • As for the language, I don't know. Its a hybrid of C and C++ according to the help files – Reidacus Jul 07 '14 at 16:52

1 Answers1

0

Please don't use the print() function. Use the op_prg_odb_print_major() function.

Objid is a special data type in Modeler. You can't print it to screen.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Allen Kim
  • 71
  • 2