2023-05-18 01:35 AM
When I compile my project from CubeMX generated project, I get the compile error:
../../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:658:29: error: expected identifier before '(' token
Now that line reads:
#define USB ((USB_TypeDef *)USB_BASE)
I am using the STM32F103C8Tx
I have not configured any USB devices or anything.
Any suggestions?
Solved! Go to Solution.
2023-05-19 12:35 AM
In radiocontroller.h you have:
typedef enum {
LSB = 0x00,
USB = 0x01,
CW = 0x02,
CWR = 0x03,
AM = 0x04,
FM = 0x08,
DIG = 0x0A,
PKT = 0x0C,
FMN = 0x88,
} operating_mode;
#endif
which uses the "USB" symbol in an unexpected manner. That's probably where the error originates: you should've given us all the surrounding information the compiler outputs together with the error itself.
You also #define USB yourself in ComputerAidedTransceiver.h
While you can work around the problem with creating a local copy (i.e. copy it into the directory where you hold your own headers) of the CMSIS-mandated header, and modify it, utilizing the order in which compiler searches for #include files; the clean solution is to avoid using the "USB" symbol in your sources. You don't seem to use them anywhere (unless I've overlooked something).
JW
2023-05-18 02:42 AM
Hello @PGild.1 and welcome to the community,
The solution for that error is to add paths to the project following this method:
right click project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> MCU GCC Compiler -> Include paths .
For this line: #define USB ((USB_TypeDef *)USB_BASE). It is expected.
In fact, STM32CubeF1 firmware gathers all the generic embedded software components required to develop an application on STM32F1 that's why it includes the defines of the USB component.
Thanks,
Rim.
2023-05-18 02:48 AM
The "problem" goes away, when I delete that line.
That is NOT a proper solution. The file is regenerated/copied by CubeMX when I change something there.
2023-05-18 02:55 AM - edited 2023-11-20 05:09 AM
Thank you for your swift response.
But it does not work.
The files are in the filesystem, but for some reason I had to give an absolute path to the IDE. Below are my current PATHS:
The problematic header file is in that directory.
2023-05-18 03:01 AM
Is the solution then to "always" delete that USB line?
2023-05-18 07:17 AM
As I did previously note the defines are generated from STM32CubeF1 firmware that's why they will be regenerated in this file "../../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h" by CubeMX when making any other changes.
From my side when I generated a project using the IOC that you attached (CubeMX 6.8.0 CubeIDE 1.12.0 and STM32CubeF1 V 1.7.0) no build errors appear. So for further analysis, Could you please provide:
2023-05-18 11:04 PM
Hello Rim LANDOLSI,
Please find attached a tar.xz of my whole project.
The information asked:
Stm32CubeIDE version:
Version: 1.12.1
Build: 16088_20230420_1057 (UTC)
STM32CubeMX version: 6.8.0
STM32CubeF1 FW: STM32CUBE_FW_F1_V1.8.5
Currently I find that if I comment that "USB define" out, the code builds and runs.
2023-05-19 12:35 AM
In radiocontroller.h you have:
typedef enum {
LSB = 0x00,
USB = 0x01,
CW = 0x02,
CWR = 0x03,
AM = 0x04,
FM = 0x08,
DIG = 0x0A,
PKT = 0x0C,
FMN = 0x88,
} operating_mode;
#endif
which uses the "USB" symbol in an unexpected manner. That's probably where the error originates: you should've given us all the surrounding information the compiler outputs together with the error itself.
You also #define USB yourself in ComputerAidedTransceiver.h
While you can work around the problem with creating a local copy (i.e. copy it into the directory where you hold your own headers) of the CMSIS-mandated header, and modify it, utilizing the order in which compiler searches for #include files; the clean solution is to avoid using the "USB" symbol in your sources. You don't seem to use them anywhere (unless I've overlooked something).
JW
2023-05-19 01:01 AM
Thank you so much Jan,
That was exactly what was wrong.
It never crossed my mind. Even though I saw the warning (which I should not have ignored in the IDE).
Thank you so much for taking the time to review the questions on these boards.