"expected identifier before '(' token" error during build
I am building a project which is a slightly modified version of BLE_Sample_App provided by ST. Before my last modifications, the IDE was succesfully building it. However, when I added some new functionality to the main code and added a couple of new source&header files, the IDE started complaining about line104 of stm32l4xx_hal_gpio.h, which is the definition of GPIO_PIN_2. The corresponding code part is below:
/* Exported constants --------------------*/
/** @defgroup GPIO_Exported_Constants GPIO Exported Constants
* @{
*/
/** @defgroup GPIO_pins GPIO pins
* @{
*/
- define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */
- define GPIO_PIN_1 ((uint16_t)0x0002) /* Pin 1 selected */
- define GPIO_PIN_2 ((uint16_t)0x0004) /* Pin 2 selected */
- define GPIO_PIN_3 ((uint16_t)0x0008) /* Pin 3 selected */
- define GPIO_PIN_4 ((uint16_t)0x0010) /* Pin 4 selected */
- define GPIO_PIN_5 ((uint16_t)0x0020) /* Pin 5 selected */
- define GPIO_PIN_6 ((uint16_t)0x0040) /* Pin 6 selected */
- define GPIO_PIN_7 ((uint16_t)0x0080) /* Pin 7 selected */
- define GPIO_PIN_8 ((uint16_t)0x0100) /* Pin 8 selected */
- define GPIO_PIN_9 ((uint16_t)0x0200) /* Pin 9 selected */
- define GPIO_PIN_10 ((uint16_t)0x0400) /* Pin 10 selected */
- define GPIO_PIN_11 ((uint16_t)0x0800) /* Pin 11 selected */
- define GPIO_PIN_12 ((uint16_t)0x1000) /* Pin 12 selected */
- define GPIO_PIN_13 ((uint16_t)0x2000) /* Pin 13 selected */
- define GPIO_PIN_14 ((uint16_t)0x4000) /* Pin 14 selected */
- define GPIO_PIN_15 ((uint16_t)0x8000) /* Pin 15 selected */
- define GPIO_PIN_All ((uint16_t)0xFFFF) /* All pins selected */
- define GPIO_PIN_MASK ((uint32_t)0x0000FFFF) /* PIN mask for assert test */
What I don’t get is, why it is giving an error only for GPIO_PIN_2? I checked the other places this definition is used, but in those two other places, the new definitions are also legit. Finally, below is the console output when I try to build my project:
11:20:35 **** Incremental Build of configuration Release for project STM32L4xx-SensorTile ****
make all
Building file: /home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Src/TargetPlatform.c
Invoking: MCU GCC Compiler
/home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/SW4STM32/STM32L4xx-SensorTile/Release
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=c99 -DUSE_HAL_DRIVER -DSTM32_SENSORTILE -DSTM32L476xx -DUSE_STM32L4XX_NUCLEO -I”/home/msrl/Magnes/stm32/Drivers/CMSIS/Device/ST/STM32L4xx/Include” -I”/home/msrl/Magnes/stm32/Drivers/STM32L4xx_HAL_Driver/Inc” -I”/home/msrl/Magnes/stm32/Drivers/BSP/SensorTile” -I”/home/msrl/Magnes/stm32/Drivers/CMSIS/Include” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/Common” -I”/home/msrl/Magnes/stm32/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/includes” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/lsm6dsm” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/hts221” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/lps22hb” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/lsm303agr” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/stc3115” -I”/home/msrl/Magnes/stm32/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc” -I”/home/msrl/Magnes/stm32/Middlewares/ST/STM32_USB_Device_Library/Core/Inc” -I”/home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Inc” -I/home/msrl/Magnes/stm32/Drivers/BSP/SensorTile -Os -Wall -fmessage-length=0 -ffunction-sections -c -MMD -MP -MF”MotEnv1_ST/User/TargetPlatform.d” -MT”MotEnv1_ST/User/TargetPlatform.o” -o “MotEnv1_ST/User/TargetPlatform.o” “/home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Src/TargetPlatform.c”
In file included from /home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Src/TargetPlatform.c:45:0:
/home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Inc/main.h:111:16: warning: ‘HeelStrike’ declared ‘static’ but never defined -Wunused-function
static uint8_t HeelStrike(void);
static uint8_t ToeOff(void);
static uint8_t ToeOffDiabetes(void);
static uint8_t NoMotion( void );
Finished building: /home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Src/TargetPlatform.c
Building file: /home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Src/clock.c
Invoking: MCU GCC Compiler
/home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/SW4STM32/STM32L4xx-SensorTile/Release
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=c99 -DUSE_HAL_DRIVER -DSTM32_SENSORTILE -DSTM32L476xx -DUSE_STM32L4XX_NUCLEO -I”/home/msrl/Magnes/stm32/Drivers/CMSIS/Device/ST/STM32L4xx/Include” -I”/home/msrl/Magnes/stm32/Drivers/STM32L4xx_HAL_Driver/Inc” -I”/home/msrl/Magnes/stm32/Drivers/BSP/SensorTile” -I”/home/msrl/Magnes/stm32/Drivers/CMSIS/Include” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/Common” -I”/home/msrl/Magnes/stm32/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/includes” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/lsm6dsm” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/hts221” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/lps22hb” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/lsm303agr” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/stc3115” -I”/home/msrl/Magnes/stm32/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc” -I”/home/msrl/Magnes/stm32/Middlewares/ST/STM32_USB_Device_Library/Core/Inc” -I”/home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Inc” -I/home/msrl/Magnes/stm32/Drivers/BSP/SensorTile -Os -Wall -fmessage-length=0 -ffunction-sections -c -MMD -MP -MF”MotEnv1_ST/User/clock.d” -MT”MotEnv1_ST/User/clock.o” -o “MotEnv1_ST/User/clock.o” “/home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Src/clock.c”
Finished building: /home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Src/clock.c
Building file: /home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Src/main.c
Invoking: MCU GCC Compiler
/home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/SW4STM32/STM32L4xx-SensorTile/Release
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=c99 -DUSE_HAL_DRIVER -DSTM32_SENSORTILE -DSTM32L476xx -DUSE_STM32L4XX_NUCLEO -I”/home/msrl/Magnes/stm32/Drivers/CMSIS/Device/ST/STM32L4xx/Include” -I”/home/msrl/Magnes/stm32/Drivers/STM32L4xx_HAL_Driver/Inc” -I”/home/msrl/Magnes/stm32/Drivers/BSP/SensorTile” -I”/home/msrl/Magnes/stm32/Drivers/CMSIS/Include” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/Common” -I”/home/msrl/Magnes/stm32/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/includes” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/lsm6dsm” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/hts221” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/lps22hb” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/lsm303agr” -I”/home/msrl/Magnes/stm32/Drivers/BSP/Components/stc3115” -I”/home/msrl/Magnes/stm32/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc” -I”/home/msrl/Magnes/stm32/Middlewares/ST/STM32_USB_Device_Library/Core/Inc” -I”/home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Inc” -I/home/msrl/Magnes/stm32/Drivers/BSP/SensorTile -Os -Wall -fmessage-length=0 -ffunction-sections -c -MMD -MP -MF”MotEnv1_ST/User/main.d” __-MT”MotEnv1_ST/User/main.o” -o “MotEnv1_ST/User/main.o” “/home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Src/main.c”
In file included from /home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Inc/stm32l4xx_hal_conf.h:195:0,
from /home/msrl/Magnes/stm32/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h:48,
from /home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Inc/TargetFeatures.h:55,
from /home/msrl/Magnes/stm32/Projects/SensorTile/Applications/BLE_SampleApp/Src/main.c:48:
/home/msrl/Magnes/stm32/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_gpio.h:104:36: error: expected identifier before ‘(’ token
#define GPIO_PIN_2 ((uint16_t)0x0004) /* Pin 2 selected */__
MotEnv1_ST/User/subdir.mk:58: recipe for target ‘MotEnv1_ST/User/main.o’ failed
make: *** MotEnv1_ST/User/main.o Error 1
11:20:36 Build Finished (took 914ms)
It would be great if anyone could help me with this.