Compile error with lte_lc on nrf Connect SDK v1.9.0 with c++

Hello,

With UDP Sample switched to c++ (main.c -> main.cpp and added CONFIG_CPLUSPLUS=y, CONFIG_LIB_CPLUSPLUS=y) i get compilation error on including lte_lc.h

In file included from d:\Projects\Zen\UDPSampleApp\src\main.cpp:9:
C:\Users\nicolae.georgescu\ncs\v1.9.0\nrf\include\modem\lte_lc.h:640:10: error: 'struct lte_lc_periodic_search_pattern::<unnamed union>::lte_lc_periodic_search_range_cfg' invalid; an anonymous union may only have public non-static data members [-fpermissive]
640 | struct lte_lc_periodic_search_range_cfg {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\nicolae.georgescu\ncs\v1.9.0\nrf\include\modem\lte_lc.h:689:10: error: 'struct lte_lc_periodic_search_pattern::<unnamed union>::lte_lc_periodic_search_table_cfg' invalid; an anonymous union may only have public non-static data members [-fpermissive]
689 | struct lte_lc_periodic_search_table_cfg {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I am using the latest sdk v1.9.0 from Toolchain Manager.

Do you have any suggestions?

Thanks,

Nicolae

Parents
  • Hi,

    It seems to be related to anonymous unions and structs, and how they can be nested, in various versions of C and C++, although I am not 100 % sure what is the exact issue.

    In any case:

    Are the file change from main.c to c++ and added configs CONFIG_CPLUSPLUS and CONFIG_LIB_CPLUSPLUS the only changes you have done to the project?

    What toolchain and compiler (including version numbers) are you using?

    It may be for instance that the compiler is set to use C98 for the extern C portions while the code is only valid for C11, or that you need to add some compiler extensions for it to work.

    Regards,
    Terje

  • Hi Terje,

    Thanks for looking into this!

    Are the file change from main.c to c++ and added configs CONFIG_CPLUSPLUS and CONFIG_LIB_CPLUSPLUS the only changes you have done to the project?
    [Nicolae] Yes. It's UDP Sample with just these changes, and the CMakeLists.txt to point to the cpp file.

    I have the following setup:
    - windows 10
    - nrf Connect for Desktop v3.10.0
    - ToolChain Manager latest (v0.10.3) with nRF Conect SDK v1.9.0 (latest i see in toolchain)
    - VSCode with selected v1.9.0 (pic attached)


    About the compiler. Where can i check which compiler i am using? In the error description there is a -std=c++11, also highlited in the attachement.



    Thanks,
    Nicolae

  • Hi,

    The failing command is calling arm-none-eabi-g++.exe from the ncs toolchain directory. It is the GCC C++ compiler for the ARM target.

    I need to consult the nRF Connect SDK team on this one. Although C++ should be possible in theory, we are primarily targetting C. We may find a solution for this, and patch for an upcoming nRF Connect SDK release, but it may take some time. Until we have identified the issue I recommend that you look further into it at your end as well. I am sure there are also support forums or channels for GCC that can help out in figuring out what is going on, and/or what settings (if any) can be tweaked in order for GCC to accept the C code.

    Regards,
    Terje

Reply
  • Hi,

    The failing command is calling arm-none-eabi-g++.exe from the ncs toolchain directory. It is the GCC C++ compiler for the ARM target.

    I need to consult the nRF Connect SDK team on this one. Although C++ should be possible in theory, we are primarily targetting C. We may find a solution for this, and patch for an upcoming nRF Connect SDK release, but it may take some time. Until we have identified the issue I recommend that you look further into it at your end as well. I am sure there are also support forums or channels for GCC that can help out in figuring out what is going on, and/or what settings (if any) can be tweaked in order for GCC to accept the C code.

    Regards,
    Terje

Children
No Data
Related