platformio / platform-nordicnrf51

Nordic nRF51: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/nordicnrf51
Apache License 2.0
20 stars 25 forks source link

readBearLabBLENano board fails to compile when including mbed.h on macOS #20

Closed agatti closed 6 years ago

agatti commented 6 years ago

Using the following settings in platformio.ini:

[platformio]
env_default = redBearLabBLENano

[env:redBearLabBLENano]
; platform = nordicnrf51 -- does not matter whether stable or git
platform = https://github.com/platformio/platform-nordicnrf51.git
framework = mbed
board = redBearLabBLENano

and the following sample code:

#include "mbed.h"

int main()
{
    return 0;
}

running platformio run fails with the following error:

[Tue Jan 30 10:38:10 2018] Processing redBearLabBLENano (platform: https://github.com/platformio/platform-nordicnrf51.git; board: redBearLabBLENano; framework: mbed)
----------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Collected 14 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/redBearLabBLENano/src/main.o
In file included from /Users/agatti/.platformio/packages/framework-mbed/mbed.h:54:0,
from src/main.c:1:
/Users/agatti/.platformio/packages/framework-mbed/platform/platform.h:22:19: fatal error: cstddef: No such file or directory
#include <cstddef>
^
compilation terminated.
*** [.pioenvs/redBearLabBLENano/src/main.o] Error 1
============================================= [ERROR] Took 1.47 seconds =============================================

Not including mbed.h does compile and everything, but it is a bit of a problem if I cannot even include the framework basic include file. Is there anything else I should check for troubleshooting the issue or to see if I did anything wrong here?

Thank you for your time, Alessandro

agatti commented 6 years ago

And for completeness' sake, here is the output of platformio run -v:

[Tue Jan 30 10:43:06 2018] Processing redBearLabBLENano (platform: https://github.com/platformio/platform-nordicnrf51.git; board: redBearLabBLENano; framework: mbed)
----------------------------------------------------------------------------------------------------------------------
Collected 14 compatible libraries
Scanning dependencies...
No dependencies
arm-none-eabi-gcc -o .pioenvs/redBearLabBLENano/src/main.o -c -std=gnu99 -DMBED_RTOS_SINGLE_THREAD -mcpu=cortex-m0 -mthumb -c -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections -funsigned-char -MMD -fno-delete-null-pointer-checks -fomit-frame-pointer -Os -DNDEBUG -g1 -include mbed_config.h -D__CMSIS_RTOS -DTARGET_MCU_NORDIC_16K -DTARGET_NORDIC -DTOOLCHAIN_object -DTARGET_RBLAB_BLENANO -DDEVICE_PORTIN=1 -DTARGET_NRF51822 -DTARGET_MCU_NRF51_16K_S130 -DCMSIS_VECTAB_VIRTUAL -DTARGET_MCU_NRF51822 -DDEVICE_SPISLAVE=1 -DDEVICE_I2C=1 -DCMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\" -DDEVICE_PORTINOUT=1 -DTARGET_M0 -D__MBED_CMSIS_RTOS_CM -DARM_MATH_CM0 -DTARGET_RELEASE -DTARGET_LIKE_MBED -DTARGET_MCU_NRF51_16K_BASE -D__MBED__=1 -DDEVICE_SERIAL=1 -D__CORTEX_M0 -DMBED_BUILD_TIMESTAMP=1516293186.71 -DDEVICE_INTERRUPTIN=1 -DDEVICE_PWMOUT=1 -DFEATURE_BLE=1 -DTARGET_LIKE_CORTEX_M0 -DDEVICE_SPI=1 -DDEVICE_SLEEP=1 -DTOOLCHAIN_GCC_ARM -DTARGET_MCU_NRF51 -DDEVICE_ANALOGIN=1 -DTARGET_UVISOR_UNSUPPORTED -DTARGET_CORTEX_M -DNRF51 -DTOOLCHAIN_GCC -DDEVICE_PORTOUT=1 -DTARGET_MCU_NRF51_16K -DTARGET_CORTEX -DARDUINO_BLE_NANO -DPLATFORMIO=30501 -I/Users/agatti/.platformio/packages/framework-mbed -I/Users/agatti/.platformio/packages/framework-mbed/cmsis -I/Users/agatti/.platformio/packages/framework-mbed/cmsis/TARGET_CORTEX_M -I/Users/agatti/.platformio/packages/framework-mbed/drivers -I/Users/agatti/.platformio/packages/framework-mbed/hal -I/Users/agatti/.platformio/packages/framework-mbed/hal/storage_abstraction -I/Users/agatti/.platformio/packages/framework-mbed/platform -I/Users/agatti/.platformio/packages/framework-mbed/targets -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822 -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130 -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nordic_sdk -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nordic_sdk/components -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nordic_sdk/components/libraries -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nordic_sdk/components/libraries/crc16 -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nordic_sdk/components/libraries/scheduler -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nordic_sdk/components/libraries/util -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_8_0_0 -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s130_nrf51822_1_0_0 -I/Users/agatti/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/TARGET_RBLAB_BLENANO -I/Users/agatti/.platformio/packages/framework-mbed -I/Users/agatti/.platformio/packages/framework-mbed/platformio/variants/RBLAB_BLENANO -Isrc src/main.c
In file included from /Users/agatti/.platformio/packages/framework-mbed/mbed.h:54:0,
from src/main.c:1:
/Users/agatti/.platformio/packages/framework-mbed/platform/platform.h:22:19: fatal error: cstddef: No such file or directory
#include <cstddef>
^
compilation terminated.
*** [.pioenvs/redBearLabBLENano/src/main.o] Error 1
============================================= [ERROR] Took 1.45 seconds =============================================
agatti commented 6 years ago

Nevermind, apparently platformio does not force C++ mode on files by default - renaming the main file from main.c to main.cpp did make things work as expected... My apologies.