Nvc++ google test fails to compile

google test github issue: GTEST_CAN_STREAM_RESULTS_ issue with PGI opecnacc compiler · Issue #3390 · google/googletest · GitHub

error

"/usr/include/x86_64-linux-gnu/bits/socket.h", line 282: error: incomplete type is not allowed
      __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data.  */

somewhat similar looking (old) bug from redhat: 53984 – /usr/include/bits/socket.h struct cmsghdr broken

does nvc++ support socket/network programming out of the box?

I’d appreciate if someone from nvidia could post on the github issue to move things along promptly!

Thanks

Hi dekken,

does nvc++ support socket/network programming out of the box?

“bit/socket.h” is a system header file so not something we’d support.

I’ve tried to reproduce the issue here so I can investigate the cause of this error, but including “sys/sockert.h” works fine for me and I’m able to successfully compile “goggletest”.

Can you please provide a reproducing example or give instructions on how you compile “goggletest” to reproduce the error? Also, please provide the OS and compiler version you’re using.

Thanks,
Mat

This error in socket.h appears to only be given when attempting to compile with the “-A” flag, which I have honestly no idea where it’s coming from in our cmake project but I will have a look.

cmake -DCMAKE_CXX_FLAGS="-A"   .. && make

That fails for me

Thanks, this makes more sense now. “-A” causes the front-end C++ compiler to enable strict language compliance and was added by Kitware a few years ago when a cmake project requests a C++ language standard (though I’ve forgotten off-hand what the specific cmake option is). We’ve needed to work through a few of these since they made this change.

In this case, it looks like the spot in socket.h which triggers this error is guarded by some type of C99 define so I’m not sure if this is indeed non-conforming to C++11 or if the front-end is being overly picky. I’ve sent a report to engineering to investigate, tracked as TPR #30030.

The work-around is to not use “-A”.

-Mat

1 Like

The work-around is to not use “-A”.

Yes indeed, I was able to figure out (I think at least) how cmake was adding this flag so it’s all good now thank you!

when a cmake project requests a C++ language standard (though I’ve forgotten off-hand what the specific cmake option is).

Yes, our call to CMAKE_CXX_STANDARD was before adding in our dependencies (like gtest), so we just rearranged them.

FYI, engineering took a look believe the error is the correct behavior since ANSI C does not allow flexible array as the last element of a struct.

Explanation:

The last field that was recorded was an incomplete array. This is permitted in C mode (as an extension), in C99 mode, and in GNU (most versions) and Microsoft mode (both C and C++). If this is an early GNU mode or a strict-ANSI-C89 mode, issue a diagnostic. Otherwise, mark class_type as containing an incomplete array member, since there are constraints on how it can be used. (E.g., it can’t be the element type of an array, and in Microsoft and GNU C++ modes it can’t be used as a base class.)

Note that we did work with Kitware to remove the “-A” flag when using cmake 3.19+.