0

I am trying to write a class for an Arduino library. I am having a hard time getting it to allow me to pass a string variable to a method within the class.

I keep getting:

...Calc.h:21: error: 'String' has not been declared

Referring to this line of code which is line 21 in Calc.h:

void printCalc(int a, int b, String s);

I don't understand why it says that it has not been declared, because there are no problems with my int's. and I didn't do anything different with them.

2 Answers 2

1

You need to #include the header file that defines String before calc.h. calc.h should be the one to #include the header where String lives, but I see this mistake quite a bit with library developers.

Sign up to request clarification or add additional context in comments.

Comments

0

Did you #include the header where String is declared? Maybe this one:

#include <WString.h>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.