New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compilation warning: ISO C++ prohibits anonymous structs #2303
Comments
Theoretically it would be possible to avoid it with an array and three reference members initialized to point to the elements of the array in order to remain strictly standard-compliant without changing the the structure API, but reference members increase the size of the class. |
Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs. |
Until C++ comes with a better method for type-punning than the one in C, PCL will have to rely on this UB. Even though this is strictly a UB, all compilers we test with provide the same behavior as a C code. Alternatives that don't increase memory size (reference) or require breaking API (using functions everywhere) are welcome. I now There's not much that's actionable here. Sorry. |
Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs. |
GCC users can disable this warning using |
I'm not sure this is considered UB as of C++11. The user compiled pcl 1.8.1 which is in C++03. According to cpp reference, anonymous structs are a part of the standard from C++11 onwards
|
Using anonymous structs is legal, it's assigning to the struct members then accessing them the array which is still considered UB today. |
I've recently encountered this problem when trying to include
I haven't yet figured out how to compile my code with
And none of those have gotten me past this compilation error. Can anyone give me more specific instructions on how to set |
/usr/include/pcl-1.10/pcl/octree/octree_key.h:155:9: error: ISO C++ prohibits anonymous structs [-Werror=pedantic] I haven't yet figured out how to compile my code with -fms-extensions set. But so far I've tried:
And none of those have gotten me past this compilation error. Can anyone give me more specific instructions on how to set -fms-extensions or another solution that fixes this issue? i too have the same issue can anyone tell me how to solve this |
Hello @MattSYoung @lockunkey Ubuntu : 20.04
Appreciate any response. |
I think the CMake files for you applications are wrong. They might have something like: |
@kunaltyagi
Above is the actual CMake File, where am getting errors. Would you please suggest me proper configuration? Regards, |
include_directories(
include
)
include_directories(SYSTEM
${Boost_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${GRID_MAP_INCLUDE_DIR}
) |
@kunaltyagi Thanks so much for your quick response, it built successfully now. |
Anonymous structs are used in PCL for type punning: PointCloudLibrary/pcl#2303 Subobject braces are not needed: https://bugs.llvm.org/show_bug.cgi?id=21629 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137 Signed-off-by: Robin Petereit <robin.petereit@de.bosch.com>
Your Environment
Context
I'm compiling my code with -pedantic and GCC gives a warning of a struct in /usr/local/include/pcl-1.8/octree/octree_key.h:
Message: " ISO C++ prohibits anonymous structs" so I guess this is non-standard C++.
Expected Behavior
No warnings.
Current Behavior
Warning "ISO C++ prohibits anonymous structs"
Code to Reproduce
Compile with -pedantic
Possible Solution
Don't use anonymous structs..?
The text was updated successfully, but these errors were encountered: