Structure with a member named "major"

4 posts / 0 new
Last post
ilya_1725's picture
Offline
Last seen: 1 year 10 months ago
Joined: 04/20/2020
Posts: 24
Structure with a member named "major"

I have a simple IDL that is sending version information:

@final
struct version {
    uint16 major;
    uint16 minor;
    uint16 patch;
    uint16 build_number;
};

The generator generates a proper class `version` with all the felds. However, then during the compile I get this error:

/build/_deps/idl-build/idl/idl/version.hpp:85:13: error: In the GNU C Library, "major" is defined
 by <sys/sysmacros.h>. For historical compatibility, it is
 currently defined by <sys/types.h> as well, but we plan to
 remove this soon. To use "major", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "major", you should undefine it after including <sys/types.h>. [-Werror]
     const uint16_t& major() const OMG_NOEXCEPT {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                                                                            

Why is this error occuring? The funtion is inside its class and shouldn't conflict with any other one.

WHat is the best way to solve this, other than changing the field names?

 

 

 

Offline
Last seen: 1 month 4 weeks ago
Joined: 09/23/2018
Posts: 62

I don't see a problem when I try to replicate your issue.

What version of Connext are you using?

How are you invoking rtiddsgen?

What host platform/architecture are you on?

This is what I did on a 64-bit CentOS7 Machine:

HelloWorld.idl:

@final
struct version {
    uint16 major;
    uint16 minor;
    uint16 patch;
    uint16 build_number;
};

source /home/gary/rti_connext_dds-6.0.1/resource/scripts/rtisetenv_x64Linux3gcc4.8.2.bash

$NDDSHOME/bin/rtiddsgen -language C -example x64Linux3gcc4.8.2 HelloWorld.idl

make -f makefile_HelloWorld_x64Linux3gcc4.8.2

Compiles fine

ilya_1725's picture
Offline
Last seen: 1 year 10 months ago
Joined: 04/20/2020
Posts: 24

I use Connext 6.0.1. 

Platform: x64Linux4gcc7.3.0

rti_connext_dds-6.0.1/bin/rtiddsgen -replace -language C++11 -d idl -alwaysUseStdVector version.idl

 

Attached is the version.hpp renamed to version.c becuase the web site for some reason accepts c and cpp extention, but not hpp.

 

File Attachments: 
Offline
Last seen: 1 month 4 weeks ago
Joined: 09/23/2018
Posts: 62

I was not able to reproduce this on a  CentOS7 setup with a platform of x64Linux3gcc4.8.2,   

I was, however, able to reproduce this on a Ubuntu 18.04 setup with a platform of x64Linux4gcc7.3.0.

It looks like it's a known issue with GNU C++11 and there are some recommended workarounds on the web  (google "warning in the gnu c library major is defined").  

It doesn't seem at all related to DDS so probably the easiest thing to do is rename the fields in your idl file. 

(ps -- I will mention this to engineering and update this response if they recommend anything other than changing the field names)