Compile active file in VS Code

Sometimes I just want to compile a single file for an nRF Connect project with VS Code and the nRF Connect extension. This sometimes fails because an include file isn't found (for example <app_event_manager_priv.h> included from app_event_manager.h in my case). The file compiles fine when the whole project is built from the nRF Connect extension but not with the 'Compile Active File' function. In the terminal output I see that a lot of '-I<folder>' arguments is given to the 'arm-zephyr-eabi-gcc.exe' compiler but no path covers the <app_event_manager_priv.h> file.

I get the error when the file <app_event_manager.h> is included somewhere in my include hierarchy for a .c file.

Which file or setting do I need to edit to add include paths for the 'Compile Active File' function?

I have added includepaths to the c_cpp_properties.json which works when the whole project is built but these include paths does not seem to be used when running 'Compile Active File'.

The file app_event_manager_priv.h lives in ${workspaceFolder}/nrf/subsys/app_event_manager

Best regards /Ruben

  • No 'Compile Active File'.

    From the context menu when right clicking on the tab for the file in the editor or with the 'Compile Active File' action button for the active file in the editor.

    /Ruben

  • Hi Ruben,

    I do not see this "Compile Active File" command. I do not have the tab for the file in the editor nor does this command appear when right-clicking on the active file. I have asked internally, and it seems that we do not have "Compile Active File" command. It might be that this command came with some other extension which you installed on your system.

    Best regards,
    Dejan


  • Ah, I see. The Compile Active File is provided by the CMake Tools extension which I thought was working well together with the nRF Connect extension. But after some googling and searching in the Nordic Dev Zone I see that these two extensions might not work very well together.

    This is probably why the 'Compile Active File' action didn't work at my end to begin with.

    When I disable the CMake Tools extension, 'Compile Active File' is not available any more.

    This is probably also why 'Compile Active File' isn't working for me after some changes until I make a Pristine Build but then it really makes no sense to compile a single file anymore.

    As I said before, the original reason for me to want to compile just a single file was that for some simple errors or typos in the Zephyr macros, hundreds and hundreds of lines with warnings and errors is  produced in the terminal output and being able to compile one file at a time does sometimes help here.

    Sorry for wasting your (and my) time with this.

    Thanks /Ruben

  • Hi Ruben,

    There is no need to be sorry. Thank you for the update.

    Best regards,
    Dejan

Related