Servers by jDrones

Add string type to project

How add string variable to project? file Plane.h
I tried
#include <string>
std::string str;
but error appear.
Can I add c++ string to project?
Help please. Thanks!

1 Like

If you do not tell the exact error message, how do you expect us to help? Telepathy?? :slight_smile:

In file included from …/…/ArduPlane/mode_loiter.cpp:2:0:
…/…/ArduPlane/Plane.h:178:2: error: ‘string’ does not name a type
string tail = “asdd”;
^~~~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/ArduPlane/RC_Channel.cpp:1:0:
…/…/ArduPlane/Plane.h:178:2: error: ‘string’ does not name a type
string tail = “asdd”;
^~~~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/ArduPlane/mode_guided.cpp:2:0:
…/…/ArduPlane/Plane.h:178:2: error: ‘string’ does not name a type
string tail = “asdd”;
^~~~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/ArduPlane/altitude.cpp:16:0:
…/…/ArduPlane/Plane.h:178:2: error: ‘string’ does not name a type
string tail = “asdd”;
^~~~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/ArduPlane/tiltrotor.cpp:1:0:
…/…/ArduPlane/Plane.h:178:2: error: ‘string’ does not name a type
string tail = “asdd”;
^~~~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/ArduPlane/mode_thermal.cpp:2:0:
…/…/ArduPlane/Plane.h:178:2: error: ‘string’ does not name a type
string tail = “asdd”;
^~~~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/ArduPlane/avoidance_adsb.cpp:3:0:
…/…/ArduPlane/Plane.h:178:2: error: ‘string’ does not name a type
string tail = “asdd”;
^~~~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/ArduPlane/mode_acro.cpp:2:0:
…/…/ArduPlane/Plane.h:178:2: error: ‘string’ does not name a type
string tail = “asdd”;
^~~~~~
compilation terminated due to -Wfatal-errors.

Waf: Leaving directory `/home/andre/ardupilot/build/CUAV-X7’
Build failed
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145291275848: cxx mode_loiter.cpp -> mode_loiter.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145289677736: cxx RC_Channel.cpp -> RC_Channel.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145291275288: cxx mode_guided.cpp -> mode_guided.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145289677848: cxx altitude.cpp -> altitude.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145288751144: cxx tiltrotor.cpp -> tiltrotor.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145288749464: cxx mode_thermal.cpp -> mode_thermal.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145291273720: cxx avoidance_adsb.cpp -> avoidance_adsb.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145291274728: cxx mode_acro.cpp -> mode_acro.cpp.34.o}
(run with -v to display more information)

simple :
std::string test = “plop”;

But it doesn’t work. I tried the same. I don’t unferstand why Ardupilot doesn’t work with string

In file included from …/…/ArduPlane/Attitude.cpp:1:0:
…/…/ArduPlane/Plane.h:179:7: error: ‘string’ in namespace ‘std’ does not name a type
std::string test = “plop”;
^~~~~~
compilation terminated due to -Wfatal-errors.

Waf: Leaving directory `/home/andre/ardupilot/build/CUAV-X7’
Build failed
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145291171992: cxx mode_loiter.cpp -> mode_loiter.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145291186808: cxx servos.cpp -> servos.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145293299608: cxx avoidance_adsb.cpp -> avoidance_adsb.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145293299160: cxx Plane.cpp -> Plane.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145291187256: cxx takeoff.cpp -> takeoff.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145293298712: cxx GCS_Mavlink.cpp -> GCS_Mavlink.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145291187144: cxx tailsitter.cpp -> tailsitter.cpp.34.o}
(run with -v to display more information)
-> task in ‘bin/arduplane’ failed (exit status 1):
{task 123145293298040: cxx Attitude.cpp -> Attitude.cpp.34.o}
(run with -v to display more information)

I need to use some strings variables. How to use strings in Ardupilot correctly?
I tried #include <string>, std::string, string.h, cstring, but don’t work. don’t build. Thanks

https://ardupilot.org/dev/docs/style-guide.html#no-standard-library

2 Likes
Servers by jDrones