Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7686081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:23:54+00:00 2026-05-31T19:23:54+00:00

I have been writing a library for my project (for now I am using

  • 0

I have been writing a library for my project (for now I am using Arduino). The problem that I have is that string in C++ and in Arduino differ.

That is, I would like my library to be independent of Arduino, so I am using #include <string> and later declaring string s;. However in Arduino strings are defined by Arduino and declared String s2.

When I include my library to the sketch I get error: string: No such file or directory on the line where I try to include C++ string library (#include <string>).

Is there a way to make Arduino use C++ string library, or convert string to Arduino string when compiling?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:23:56+00:00Added an answer on May 31, 2026 at 7:23 pm

    Several things:

    1. I am not sure about your rationale of doing something independent of Arduino. Usually, programming a micro-controller is not something very modulable and may be very different of a classical computer program. If you really want to be independent of any micro-controller and any platform, you can still use C-style strings, with a char * pointing to an array of chars.
    2. Doing what you would like to do is not easy at all. First of all you would need the source code of your std::string library. Doing an #include <string> is not enough: you must also compile the string library for the AVR platform.
    3. There are some “limitations” in the way Arduino process the C++ code as compared with a classical computer program: for instance, the operators new and delete are not implemented. Moreover, other things may be needed by the std::string implementation, so lots of dependencies to manage, or a code source size too big for Arduino.

    There are some implementations of classical string tools for AVR microcontroller like Arduino, but they are done in a procedural way (and not in an object-oriented way) for C-style strings. For instance, for the avr-libc coming with avr-gcc, you can see the list of functions here:
    avr-libc string.h
    You even have the good old printf: avr-libc stdio.h

    It is possible to use them with Arduino if you add the good header files in your code, but beware of the size of your code! Just using printf can increase the size by several kilobytes, which can be huge for a microcontroller depending on your needs.

    To conclude, in my mind, the only portable way would be to use a char * string, http://arduino.cc/en/Reference/String

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing C++ Console/CMD-line applications for about a year now and would
I'm relatively new to PHP and have been writing a project using what I
I am writing a library that I would like to be portable. Thus, it
I have been writing unit tests using NUnit and Moq with my Silverlight code
I have been writing DLL on C++, that will be use in C#. DLL
I have been writing articles on the wordpress.com blog , now I am looking
I have been experimenting with writing applications that use a local SQL Database to
I have been writing some code that creates a generic blog. Its features are
I have been thinking of maybe writing a little tool that logs into SO
I have been writing a C# app that works fine on Windows. It controls

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.