2020-02-08 05:40 AM
hi
in stm32CubeIDE c++ code and standard lib (#include <iostream> or #include <iostraem.h>) not work.
i test:
'convert C to C++'
make c++ project
use only c++ code in func main() ==> 'bool a = true;'
all test not woke!!!
ya khoda
2020-02-08 07:15 AM
Create a C++ project from scratch. By default, C++ code is valid in .cpp files only. So you need to add your C++ code in a new file, say main_cpp.cpp. To keep the generated code intact (if you like HAL...), add a new header file, say main_cpp.h
#ifndef INC_MAIN_CPP_H_
#define INC_MAIN_CPP_H_
#ifdef __cplusplus
extern "C" {
#endif
void main_cpp();
#ifdef __cplusplus
}
#endif
#endif /* INC_MAIN_CPP_H_
and include it in main.c. In main(), right before the while loop in a user code section, call main_cpp();
Implement void main_cpp() in main_cpp.cpp.
> #include <iostream>
C++ streams? Where do you expect the output going to? For POSIX IO, adapt syscalls.c
2020-02-08 11:45 AM
> #include <iostream>
C++ streams? Where do you expect the output going to? For POSIX IO, adapt syscalls.c
only for add one lib of c++ use of <iostream> :grinning_face_with_sweat:
thank you
2020-02-08 02:03 PM
If you want to use bool in C files such as main.c, just #include <stdbool.h>
-- pa