2022-02-23 06:56 PM
This is running on Linux and I created a test program with the same include and compiled it with g++ without issue.
I think I need to tell CudeIDE where the standard libraries are located? If that is so, Where do I find them?
Thanks!!
Solved! Go to Solution.
2022-02-23 09:47 PM
2022-02-23 09:47 PM
#include <string.h>
JW
2022-02-24 06:57 AM
CubeIDE uses GCC under the hood. Show the full error message. Perhaps you're not in a C++ source file. How are you creating the project?
<string> is the correct library. Or rather, it is a C++ library which is separate from the C library string.h.
https://www.cplusplus.com/reference/string/
2022-02-24 09:48 AM
The project was created with the language of C++ in CubeIDE.
Here is the complete dump of the errors that occur during the build. Only the first two are interesting. I have corrected the warnings.
Description Resource Path Location Type
fatal error: string: No such file or directory main.cpp /Slave-SPI/Application/User/Core line 31 C/C++ Problem
make: *** [Application/User/Core/subdir.mk:55: Application/User/Core/main.o] Error 1 Slave-SPI C/C++ Problem
comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] main.cpp /STM32-SPI-Slave/Core/Src line 209 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 161 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 202 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 226 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 232 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 238 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 244 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 250 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 256 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 273 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 339 C/C++ Problem
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] main.cpp /STM32-SPI-Slave/Core/Src line 350 C/C++ Problem
2022-02-24 10:12 AM
Thank you sir! That did the trick. Why do I need the .h? When I write C++ outside this environment and compile it with g++ I don't need the .h on the includes.
2022-02-24 10:30 AM
Question: Why does #include <string> require me to add the .h but #include <cstdio> chokes if I add the .h?