I've tried '#include <Arduino.h>' but to no avail... any other suggestions?
Please post a full example of the problem code.
// from mylib.c
#include <Arduino.h>
#include <mylib.h>
void cheerios (int milk) {
Serial.write(milk);
}
No setup()
No loop()
No Serial.begin()
Is this really a full program ?
Please post a full example of the problem code.
// from mylib.c
#include <Arduino.h>
#include <mylib.h>void cheerios (int milk) {
Serial.write(milk);
}
Do you REALLY consider that a FULL example? Where the f**k is mylib.h? Where is setup()? Where is loop()?
// main sketch
#include <Arduino.h>
#include <mylib.h>
void setup()
{
Serial.begin(31250); // No compilation issue here
}
void loop()
{
for (int i1 = 1; i1 < 42; i1++) {
cheerios(i1);
delay(i1);
}
}
// PS, @Paul - no need for vulgarity friend ![]()
That is STILL not a full example. It WILL fail to compile for anyone but you. If you want help, post ALL of the code.
@Paul - Good point. This should now be a complete example, agreed? (and presumably one that should compile:)
// mylib.h
#ifndef MY_LIB_H
#define MY_LIB_H
#include <Arduino.h>
void cheerios(int milk);
#endif
djjb:
// from mylib.c
If it is indeed a C file and not C++, you can't use C++ classes directly.
You can create wrapper functions if it is really necessary.
Switched everything to cpp and all works well now.
To all that helped here, thank you.