Understanding the language, error messages, etc.
by yawn » Mon Dec 19, 2016 4:40 pm
Hello,
The compiler that comes with the Arduino IDE doesn't seem to like it when you have your functions or classes in separate files. Does it work ok with anothe IDE? How do you do to avoid this problem?
-
yawn
-
- Posts: 32
- Joined: Tue Dec 23, 2014 1:54 pm
-
by Sorunome » Tue Dec 20, 2016 12:51 pm
That is because you need to pre-declare the function also in the file you use them.
So lets say you have otherfile.ino:
- Code: Select all
int add(int x, int y){
return x+y;
}
Then add to the top of you main.ino:
- Code: Select all
int add(int x, int y);
-
Sorunome
-
- Posts: 629
- Joined: Sun Mar 01, 2015 1:58 pm
-
by Sorunome » Tue Dec 20, 2016 8:32 pm
You can put the class layout thing in your main.ino file, i think, and then have myclass::myfunc(int blahblahblah); in that other ino file
-
Sorunome
-
- Posts: 629
- Joined: Sun Mar 01, 2015 1:58 pm
-
by yawn » Wed Dec 21, 2016 12:32 pm
Sorunome wrote:You can put the class layout thing in your main.ino file, i think, and then have myclass::myfunc(int blahblahblah); in that other ino file
Should've tried that, thanks!
-
yawn
-
- Posts: 32
- Joined: Tue Dec 23, 2014 1:54 pm
-
by Sorunome » Wed Dec 21, 2016 1:01 pm
You might want to start using header file syntax and then #include "myclass.h"
-
Sorunome
-
- Posts: 629
- Joined: Sun Mar 01, 2015 1:58 pm
-
Return to Programming Questions
Who is online
Users browsing this forum: No registered users and 3 guests