STM32CubeIde and Error according extern"C"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-28 3:39 PM
I changed an example program for STM32F4 Discovery Board to C++ project.
When compiling the project, there are files included from BSP, which includes a definition:
extern "C".
When compiling the project, the first error is the following:
../../Drivers/BSP/STM32F4-Discovery/stm32f4_discovery.h:25:9: error: expected unqualified-id before string constant
25 | extern "C" {
| ^~~
what is the problem?
Thanks for responsing
- Labels:
-
STM32CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-29 9:30 AM
Any effort to prevent repeated inclusion of the same include file?
Closing brace matching?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-30 12:24 AM
thanks for the reply.
I cannot see these issues as the problem.
There is only one include and the HAL files are from ST not manipulated.
Stefan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-30 4:59 AM
I think I found the more source of problem:
The code is a .c (C) file and it is compiled with gcc, not g++.
The project is set to C++.
All the HAL files are of course C-files.
But the code is compiled with the #define __cplusplus.
So of course the error pops up.
What is the correct solution?
I think one is to say, all .c files will be compiled with c++ compiler.
Is this correct direction?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-30 10:48 AM
> Is this correct direction?
Short answer: no.
Conversion of CubeIDE projects to C++ had been discussed here many times, please search. Rather won't start with that again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-12 2:13 PM
Thanks for your reply.
Of course I tried searching. However, searching for C++ is not that easy.
I didn't find anything suitable.
I am very sad that you closed the post like this and no one replied to it or the solution is obviously in another post.
Apparently you are more intelligent than me and are hiding the solution to me and others by simply explaining it here.
