Skip to content

Mis-placed extern "C" in board.h #446

Closed
@ppescher

Description

@ppescher

The extern "C" block inside "board.h" may cause incorrect symbols to be defined and linker issues. See:

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include "analog.h"
#include "clock.h"
#include "core_callback.h"
#include "digital_io.h"
#include "hw_config.h"
#include "low_power.h"
#include "rtc.h"
#include "spi_com.h"
#include "stm32_eeprom.h"
#include "timer.h"
#include "twi.h"
#include "uart.h"

For example, when I added a global function in my own "variant.cpp" file, the corresponding function declaration in "variant.h" ended up being exported as a "C" symbol, causing the linker to fail with an "undefined reference" error message.

This can potentially cause similar troubles in other places and anyway it does not seem correct: any other header file does already handle extern "C" symbols and placing an "#include" directive inside an extern "C" block should be avoided.

I think only the init() function declaration in "board.h" should be made extern "C".

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions