Open Jones-S opened 9 years ago
I am not a contributor, but I have a suggestion. It sounds like printShift() belongs in a library. In the lib directory, create a directory for your library (MyLibrary). Inside of this directory create two files: MyLibrary.h and MyLibrary.cpp. Add the function to MyLibrary.cpp and add a function prototype for it in MyLibrary.h. Inside of sketch.ino add the following line to the top of the file:
#include "MyLibrary.h"
You might also need to include Arduino inside of MyLibrary.cpp:
#include <Arduino.h>
Also, if you are using Serial, you need to tell the compiler that Serial exists outside of your library using the following line:
extern HardwareSerial Serial;
You can find an example of an Arduino library that I am working on here.
Thanks for your input. I think a Library would be possible, and I also thought about that, but in my case I have such a simple code and just wanted it to divide from the other code. I don't need the hassle with libs. But I thought if I could compile them all into one file, then why not initiate another ino file. Just wondered wether I was making some mistake or if the ino tool does not support the compiling of multiple ino files. But thanks for your answer anyway. Very much appreciated. Cheers
I also have the same problem. There's no documentation on how this is resolved, unfortunately. Can a core contributor elucidate?
I am not a contributor but in an Arduino sketch you only have one ino file. Other files have to be .cpp or .h.
I use ino to build Marlin and that has lots of files in the project.
It seems that this issue can be worked around by thinking about the project like a C program. That's all well and good, but if that's the approach, why bother with .ino?
If it's useful, I've got an example commit illustrating the workaround.
In general, workaround seems to take the form:
ino preproc src/Look.ino >src/Look.h
#ifndef _Look_h
guard to Look.h#include "Look.h"
to Look.ino#ifndef
guarded.)extern
.
Hi there I'm not sure, if I'm missing out something... But I thought that in my src folder all my ino files would be compiled into one. I have a sketch.ino file with all stuff in it. and now a 2nd ino file for experimenting. that 2nd file has a function called 'printShift()' and that very function I'm calling in the setup of my main file. Unfortunately the terminal tells me:
Do you know how I can get multiple ino files to get to work? Thanks for any help on that matter.
Cheers