1

I am facing the error arduino first defined here while trying to compile my code, I think that the reason is that my class needs to have access to some variables that are defined in the header of my main skecht.ino. Simplifying I have something like this

main .ino

#include "myLibt.h"

setup(){
//setup something
}
loop(){
//loop something
}

myLibs.h looks like

#include <Arduino.h>

int x;
int y;
int z;

then I have my class that needs to access x, y and z from myLibs.h, if I do as below, including myLibs.h in the class, while compiling I get the error mentioned (arduino first defined here) for each of the variables of myLibs.h that I use. (Notice that the operations of my class are just examples)

#incldue "myLibs.h"
class A{

int a;
int b;

void m1();
  void m2(){

    x = a + x;
    z = b * z;
  }
}

Why do I have that error and how I can fix it?

1

1 Answer 1

2

The main issue consisted on having the variables x, y and z on my libs.h, moving them to the class A itself or creating a new extra class where class A have access to fixed the issue

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

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.