Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

#error directive: "Board is not defined" Visual Studio Code

Hi all. 

First I would like to apologize for any mistake because I'm posting first time here.

I'm using Visual Studio Code (VSC) to evaluate the blinky example from nRF5 SDK (located in examples/peripherals). I set up all the include paths correctly and all headers are loaded.

However, I'm having error with LEDS_NUMBER is undefined in main.c. Going to definition points to multiple headers the included in board.h.

Going to definition of board.h, I have the problem at line 87: #error "Board is not defined". The error is #error directive: "Board is not defined" . The example build just fine, and I can use Jumper Vlab to test the built file.

What could be the problem? Does VSC confused with multiple headers?

I read a similar problem with Keil, and the fix was to specify a board for Keil. Is this similar to what I've having with VSC, because this is compiler error flag, maybe VSC got confused of what board is being used?

Here are the screenshots:

main.c

board.h

  • Hi

    What board are you using? The "Board is not defined" error suggests that you're using a board that is not defined in the boards.h header file. You can check out this link to see hot to enabling support for a board or custom board in your project.

    Can you upload a complete debugger log so I can see the full log? That should give us an idea of what exactly is going wrong.

    Best regards,

    Simon

  • Hello. Thank you for the reply.

    I'm (planning on) using a PCA10059 (nRF52840 USB Dongle). 

    However the hardware hasn't arrived yet, so I'm using Jumper VLab as an emulator to emulate a PCA10040 (nRF52832). I can still debug just fine and VSC can connect to the emulator and setting LED Pins on and off. I can also build the project just fine.

    There is no debugger log though, I apology, so I'm giving detail on what I've done with this project:

    - I opened the project folder (SDK/examples/peripherals/blinky) with VSC as a workspace. (also I'm using Windows 10)

    - I setup the Include Path based on the include paths in the included Makefile. All the headers were included.

    Right after this step, the error with LEDS_NUMBER appeared.

    I hope that this can help somehow.

    Best Regards,

    Thien

  • Hello.

    Thank you for all the supports. I was able to resolve this by going to VSC C/C++ Configuration, and in the define section and define the board there. Here is the screenshot:

Related