This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

cpp - error: #29: expected an expression

Hello, I am quite new to C/C++ and Keil. I am using the following:

nrf52832_xxaa (Cortex M4)
Keil uVision 5.24.2.0

I have some existing C++ code which I had used on another project and am looking to implement it on the nrf52. However I am having problems with using Keil and C++. Specifically, on the definition of a struct, as shown below:

    const nrf_drv_twi_config_t twi_lm75b_config = {
       .scl                = ARDUINO_SCL_PIN,
       .sda                = ARDUINO_SDA_PIN,
       .frequency          = NRF_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

I am getting the following errors:

*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'nrf52832_xxaa'
compiling main.cpp...
..\..\..\main.cpp(153): error:  #29: expected an expression
         .scl                = ARDUINO_SCL_PIN,
..\..\..\main.cpp(154): error:  #29: expected an expression
         .sda                = ARDUINO_SDA_PIN,
..\..\..\main.cpp(155): error:  #29: expected an expression
         .frequency          = NRF_TWI_FREQ_100K,
..\..\..\main.cpp(156): error:  #29: expected an expression
         .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
..\..\..\main.cpp(157): error:  #29: expected an expression
         .clear_bus_init     = false
..\..\..\main.cpp(121): warning:  #177-D: function "data_handler"  was declared but never referenced
  __STATIC_INLINE void data_handler(uint8_t temp)
..\..\..\main.cpp: 1 warning, 5 errors
".\_build\nrf52832_xxaa.axf" - 5 Error(s), 1 Warning(s).
Target not created.

I have tried simplifying the case down and declaring the struct in the main.cpp,

typedef struct
{
    bool            peeled;                 ///< SCL pin number.
} apple;

void test_init (void)
{
    const apple red = {
       .peeled = true
    };
}

but the same problem occurs

*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'nrf52832_xxaa'
compiling main.cpp...
..\..\..\main.cpp(175): error:  #29: expected an expression
         .peeled = true
..\..\..\main.cpp(121): warning:  #177-D: function "data_handler"  was declared but never referenced
  __STATIC_INLINE void data_handler(uint8_t temp)
..\..\..\main.cpp: 1 warning, 1 error
".\_build\nrf52832_xxaa.axf" - 1 Error(s), 1 Warning(s).
Target not created.
Build Time Elapsed:  00:00:00

I have included my compiler settings here: https://ibb.co/imk6HG

Any help on this would be greatly appreciated

Parents Reply Children