cancel
Showing results for 
Search instead for 
Did you mean: 

Error in "stm32f103xb.h"?

PGild.1
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

8 REPLIES 8
Rim LANDOLSI
ST Employee

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.

PGild.1
Associate III

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.

PGild.1
Associate III

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:


_legacyfs_online_stmicro_images_0693W00000bkMWOQA2.pngThe problematic header file is in that directory.

PGild.1
Associate III

Is the solution then to "always" delete that USB line?

Rim LANDOLSI
ST Employee

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:

  • Stm32CubeIDE version
  • STM32CubeMX version
  • STM32CubeF1 firmware version
  • The project you are working on to see what causes this error

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.

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

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.