Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ppescher opened this issue Feb 18, 2019 · 1 comment
Closed

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

ppescher opened this issue Feb 18, 2019 · 1 comment
Assignees
Labels
bug 🐛 Something isn't working
Milestone

Comments

@ppescher
Copy link
Contributor

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".

@fpistm fpistm self-assigned this Feb 19, 2019
@fpistm
Copy link
Member

fpistm commented Feb 19, 2019

Thanks @ppescher
I see your point.

@fpistm fpistm added the bug 🐛 Something isn't working label Feb 19, 2019
@fpistm fpistm added this to the 1.5.1/1.6.0 milestone Feb 19, 2019
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Feb 19, 2019
fpistm added a commit that referenced this issue Feb 21, 2019
Fix #446

Signed-off-by: Frederic.Pillon <[email protected]>
benwaffle pushed a commit to benwaffle/Arduino_Core_STM32 that referenced this issue Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants