-1

I'm trying to implement a BSM in Veins 4.4. In order to reach this purpose I would like to import my libasn which are C files (.c and .h ) in the WaveShortMessage.msg in order to populate the BSM.

I tried to import them as follows:

  1. #include "veins/asn/BasicSafetyMessage.h"

  2. #include <veins/asn/BasicSafetyMessage.h>

3.

extern "C" {
   #include "veins/asn/BasicSafetyMessage.h"
};

4.

    #ifdef __cplusplus
    extern "C" {
    #endif
    #include "veins/asn/BasicSafetyMessage.h"
    #ifdef __cplusplus
    }
    #endif

but it doesn't work. It always returns an error.

Could you suggest the right way to do it? Thanks a lot

Toby
  • 9,696
  • 16
  • 68
  • 132
FMA
  • 33
  • 1
  • 7
  • 2
    _It always returns an error_: good to know, but which error ?? – Jabberwocky Nov 30 '16 at 11:09
  • In case 1,2 and 4 "Error: syntax error, unexpected BIN_XOR, expecting $end"; in case 3 "Error: syntax error, unexpected NAME, expecting $end". – FMA Nov 30 '16 at 11:14
  • sorry case 2 is #include – FMA Nov 30 '16 at 11:15
  • Seems like the file is included just fine, as would be expected if the compiler knows or is told where to look for it. The syntax error is just that - an error of syntax, as opposed to an error of being unable to find and include a file. These can occur (amongst other times) when incompatible versions of libraries are mixed or when files are included in the wrong order. – enhzflep Nov 30 '16 at 11:30
  • In both cases? Thanks – FMA Nov 30 '16 at 11:53

1 Answers1

2

Using a C or C++ code in the message's definition in OMNeT++ is described in details in OMNeT++ Simulation Manual, chapter 6.5.
You should use cplusplus keyword, an example for C code in BasicSafetyMessage.h:

cplusplus {{
extern "C" {
#include "veins/asn/BasicSafetyMessage.h"
};
}}
Jerzy D.
  • 6,707
  • 2
  • 16
  • 22
  • I have edited my answer and added `extern "C"`. The other way is to add `extern "C"` in your file `BasicSafetyMessage.h`. – Jerzy D. Nov 30 '16 at 12:03