[6.0] Failing to use STL containers in message by following the manual

251 views
Skip to first unread message

Thor Høgås

unread,
Jan 17, 2020, 7:32:37 AM1/17/20
to OMNeT++ Users
Hi!

I'm trying to use std::vector as a field within a message by looking at section 6.8.1 of the manual.

However, I am failing to get any further: the example posted yields two errors:
  1. Error: Type declarations are not needed with imports, try invoking the message compiler in legacy (4.x) mode using the --msg4 option
  2. Error: unknown type 'IntVector' for field 'addresses' in 'FooPacket'
I am using OMNet++ 6.0pre6, and thus I thought the manual could be out of date, and that I should look at the source manual.
Unfortunately the source manual TeX files refer to the same examples, and after I posted a question regarding this on StackOverflow, I found the changelog notice mentioning the experimental msg6 mode, which is the new default in OMNet++ 6.0.

Are there some notes or examples re: the msg6 node for looking at? Should I perhaps look at INET4?

Kind regards,
Thor

Alfonso Ariza Quintana

unread,
Jan 17, 2020, 11:02:50 AM1/17/20
to omn...@googlegroups.com
It has changed a bit

With the new format, you need to use other approach

cplusplus {{
typedef std::vector<int> MyVectorInt;
}}

class MyVectorInt { @existingClass; }

Now you can use MyVectorInt like a field inside a packet.


De: omn...@googlegroups.com <omn...@googlegroups.com> en nombre de Thor Høgås <th...@roht.no>
Enviado: viernes, 17 de enero de 2020 13:32
Para: OMNeT++ Users <omn...@googlegroups.com>
Asunto: [Omnetpp-l] [6.0] Failing to use STL containers in message by following the manual
 
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/omnetpp/5d24a7f2-bcb2-4c0c-a734-776e866d6e4a%40googlegroups.com.

Thor Høgås

unread,
Jan 17, 2020, 11:26:01 AM1/17/20
to omn...@googlegroups.com
On Fri, Jan 17, 2020 at 5:02 PM Alfonso Ariza Quintana <aari...@hotmail.com> wrote:
It has changed a bit

With the new format, you need to use other approach

cplusplus {{
typedef std::vector<int> MyVectorInt;
}}

class MyVectorInt { @existingClass; }

Now you can use MyVectorInt like a field inside a packet.

Thank you, Alfonso. I also got a reply from Rudi at Stack Overflow. Hopefully, anyone else poking around will find the answer quick and easy.

Kind regards,
Thor
Reply all
Reply to author
Forward
0 new messages