Getting "not declared in this scope" errors only after build

Hello, I’m having trouble with errors in some of my included .cpp files. Before I compile the project, no error appears, but after compilation, I get errors in only some of the files.

The compiler fails to understand basic arduino functions such as digitalRead and pin definitions.

It acts as if the .cpp file wasn’t included in the main file, but it definitely is.

It’s weird to me that the errors are only in 3 files, 3 other files are unaffecte even though thy’re included in the same way (all files are in src folder, linked with #include in the main file)

Anyone knows what the problem is?

You didn’t show the whole source file. Is #include <Arduino.h> at the start, which is mandatory for C++ Arduino programs?

1 Like