Loading...
 

System Workbench for STM32


Syntax error about "__weak","__attribute__((weak))"

a sw4stm32 project generated by stm32cubemx, and I use Ubuntu linux 14.04 OS,
There is a problem,when I build the project ,an error occurred:

Description	Resource	Path	Location	Type
make: *** [Drivers/STM32F4xx_HAL_Driver/stm32f4xx_hal.o] Error 1

in file stm32f4xx_hal.c:

__weak void HAL_MspDeInit(void)
{
  /* NOTE : This function Should not be modified, when the callback is needed,
            the HAL_MspDeInit could be implemented in the user file
   */ 
}

Syntax erro at “__weak”, but I have add settings in

Properties->C/C++ General->Path and Symbols->Symbols

Symbol		Value
__weak		"__attribute__((weak))"+-


How to fix this problem?

France

Hi,

Are you sure you set this symbol for the whole project? You must select the project before opening the properties dialog, otherwise you set these properties only on the currently selected element.

Could you cut&paste the offending compilation log (in the console window)?

Bernard (Ac6)

Thank you again,
I have resolved this problem,
the reason is , I add -std=c99 in a wrong format,now I choose it in Properties->C/C++ Build->Dialect-> Language standard
It’s working


I wonder why you do that. It is defined in stm32f4xx_hal_def.h

In fact it is included in all stm32f4xx_hal_xxxxxx.h

not me, stm32cubemx do that by default,,

I just want to make my IDE support C99

France

There is two possibilities here:

  1. Either you just want to be able to use C99 features; in this case you don’t have to do anything, as the default selection for GCC is -std=gnu11, that is C11 plus GNU extensions, so it supports C99.
  2. Either you want to be sure you are fully C99 conformant to standard iso9899:1999, with no GNU extensions, then you should effectively select -std=c99, but you should also add -Wpedantic, as otherwise it will still accept some GNU extensions, as well as some c11 features...

BTW, the default for C is -std=gnu11 and for C++ it’s -std=gnu98.

Hope this helps,

Bernard (Ac6)

Thank you, your answers are helpful ,
and I resolved this problem .



The problem here is that the value of the symbol should NOT contain any quotes!

Every f***ing time I regenerate the sources of my project with CubeMX, I have to remove those quotes. They don’t belong there and certainly result in invalid syntax (from the CDT Indexer point of view).

The quotes seem to be stripped when the compiler command is generated. So nobody seems to notice the error.

Thanks skoehler, for that ranty suggestion. That solved it for me! :-)
I don’t understand what you mean about the CDT Indexer POV but getting rid of the quotes made the warnings go away and those functions became available in the project.

http://www.openstm32.org/forumthread2733#threadId6864|Question
Every f***ing time I regenerate the sources of my project with CubeMX, I have to remove those quotes. They don’t belong there and certainly result in invalid syntax (from the CDT Indexer point of view).