C++ support (Eclipse CDT4) - 'printk' could not be resolved #west


Leo
 

Hello!

I am failing to create a Zephyr project for Eclipse with C++ support.
Is there a working example or guide I can use as reference to set this up?
My end goal is to use Zephyr + nRF SDK in C++ with debugging in any IDE, preferably SEGGER or Eclipse.

After importing project "hello_world", Eclipse underlines function "printk" in red:
    ==> Function 'printk' could not be resolved <==
    ==> Symbol 'CONFIG_BOARD' could not be resolved <==

Here's the steps I follow to setup the project:
    Toolchain:
        Zephyr 2.0.0
        west v0.6.0
        ninja 1.9.0
        cmake 3.15.2
        Eclipse 4.12 + GNU MCU 4.5.1
    
    Edit prj.conf and .config:
        CONFIG_PRINTK=y
        CONFIG_STDOUT_CONSOLE=y
        CONFIG_NEWLIB_LIBC=y
        CONFIG_LIB_CPLUSPLUS=y
    
    Run:
        west build -b nrf52840_pca10056 C:/embedded/zephyrproject/zephyr/samples/hello_world -- -G"Eclipse CDT4 - Ninja" -D_ECLIPSE_VERSION=4.12
        One warning:
            <...>
            [18/98] Building CXX object CMakeFiles/app.dir/src/main.cpp.obj
            cc1plus.exe: warning: command line option '-Wno-pointer-sign' is valid for C/ObjC but not for C++
    
    Import project into Eclipse
        Error in main.cpp:
        Function 'printk' could not be resolved
    
    Also tried:
        set (CMAKE_CXX_STANDARD 11) in CMakeLists.txt
        Manually add "__cplusplus=201402L" as a symbol in Eclipse (cmake does not generate such symbol in .cproject)
        Force boilerplate.cmake to call eclipse_cdt4_generator_amendment with work mode = 2 (.cproject with __cplusplus)
    
Thanks!

Join users@lists.zephyrproject.org to automatically receive all group messages.