I tried to use the std:string
class on the Arduino Platform in Spresense, and when I tried #include<string>
, I encountered a compilation error.
Is the C++ standard library unavailable?
Code:
#include<string>
void setup() {
// put your setup code here, to runonce:
}
void loop() {
// put your main code here, to run repeatly:
}
Error message:
Infile included from c:\users\takashi\documents\arduinodata\packages\spresense\tools\gcc-arm-none-eabi\5.4.1\windows\arm-none-eabi\include\c++\5.4.1\bits\stl_algobase.h61:
from c:\users\takashi\documents\arduinodata\packages\spresense\tools\gcc-arm-none-eabi\5.4.1\windows\arm-none-eabi\include\c++\5.4.1\bits\char_traces.h:39,
from c:\users\takashi\documents\arduinodata\packages\spresense\tools\gcc-arm-none-eabi\5.4.1\windows\arm-none-eabi\include\c++\5.4.1\string:40,
from C:\Users\takashi\AppData\Local\Temp\arduino_modified_sketch_278803\sketch_jul17a.ino:1:
c:\users\takashi\documents\arduinodata\packages\spresense\tools\gcc-arm-none-eabi\5.4.1\windows\arm-none-eabi\include\c++\5.4.1\bits\cpp_type_trits.h:168:12:error:redefinition'ofign_construction&starting:
structure__is_integer<unsigned char>
^
c:\users\takashi\documents\arduinodata\packages\spresense\tools\gcc-arm-none-eabi\5.4.1\windows\arm-none-eabi\include\c++\5.4.1\bits\cpp_type_trites.h:147:12:previable_ofignition; construction&starting:
structure__is_integer<bool>
^
(post on Sony developer forum)
spresense
Community Bot activated this post and caught my eye, so I gave it a try.
I tried the following code provided in the latest board package (2.3.0) and compiled it without any problems.
#include<string>
void setup() {
// put your setup code here, to runonce:
}
void loop() {
// put your main code here, to run repeatly:
}
It seems that you responded at some time.
For Arduino, it seems to use String Object.
https://www.arduino.cc/reference/en/language/variables/data-types/stringobject/
I could use this normally.
I read the error message.
c:\users\takashi\documents\arduinodata\packages\spresense\tools\gcc-arm-none-eabi\5.4.1\windows\arm-none-eabi\include\c++\5.4.1\bits\cpp_type_trites.h:168:12:error:redefinition' condition' of ___beginner:
[Direct translation] Error: 'struct std::__is_integer' is redefined.
structure_is_integer<unsigned char>
c:\users\takashi\documents\arduinodata\packages\spresense\tools\gcc-arm-none-eabi\5.4.1\windows\arm-none-eabi\include\c++\5.4.1\bits\cpp_type_trites.h:147:12:error:previous deployment
[Direct translation] Error: The previous definition of 'struct std::__is_integer' was
structure_is_integer<bool>
==
You're saying it's no good because the definitions of "struct__is_integer<unsigned char>" and "struct_is_integer<bool>" are covered, but if you read it honestly, "unsigned char" and "bool" are different types, so you don't wear them.
I think that it is declared that unsigned char and bool are the same.
In the header file
#defbool unsigned char
or
# undefined charbool
Isn't there a line like this? If you have one, please leave a comment.
Then the error will disappear.
It doesn't seem to be a fundamental solution, but based on Fumu7's response
I deleted __is_integer in cpp_type_trats.h and found that
The string was successfully included.
If you don't have anything to do with _is_integer, why don't you try it?
If the library is created, no one else will be able to use it...
Arduino has a source extension of ino, but I think you can also use cpp.
Could you write #include to another file with the extension cpp and call it from ino?
© 2024 OneMinuteCode. All rights reserved.