We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Lately I'd obsessed over compiling STM32 project with ARMCLANG.
Here is Details:
Case 1. Used "#include <sstream>" in cpp file, complied successfully but execute failed, meanwhile I didn't use any function in <sstream>.
Case 2. Comment this code, project is fine.
Environment:
IDE: MDK 5.2.5
Compiler: armclang v6.9
SRC: c/c++ file.
Board: stm32f4 series(CPU Cortex-M4, Arch armv7-M).
sstream_compile_failed said:SRC: c/c++ file.
Surely, a file must be either C or C++ ?
So which is it?
c++
I mean project including both of c and c++. In case 1 I indicate that is cpp file.
But still, any one source file can only be either C or C++
Can you successfully build a purely C++ project?
There are plenty of references on the general principles of mixing C and C++ source in a project - not specific to Keil or ARM.
It's generally best to make your project a C++ project - ie, your main() function is a C++ one - to ensure that you get all the required C++ support. Then you add C files to it, using the usual approach - such as
extern "C" {
etc
See, for example, https://stackoverflow.com/questions/1041866/what-is-the-effect-of-extern-c-in-c
Thanks for your response, but it's unrelated. I just find the problem: use iostream series function in c++ files without disabling “Half Host Mode”, will result in this issue. I add "__asm(".global __use_no_semihosting");" in the head of main.cpp then the compiler comes out errorr. Then I redefined related functions(eg. fflush(), fgetc()). Now my project works fine.
sstream_compile_failed said:Half Host Mode
You mean semihosting ?
http://www.keil.com/support/man/docs/armcc/armcc_pge1358787046598.htm