I hope I am using the right forum it's arduino ide but for esp32
Having followed this tutorial:
I am trying to make esp32 work. I've had no problem following the tutorial. But when I try to compile the code using esp32 configuration I see some weird errors while the same code compiles / and runs without problem with an arduino mega configuration. The first lines:
In file included from c:\Users\mz\Documents\Arduino\libraries\ADS1256INO\ADS1256.h:1,
from c:\Users\mz\Documents\Arduino\libraries\ADS1256INO\ADS1256.cpp:1:
c:\Users\mz\Documents\Arduino\libraries\ADS1256INO\ads1256_constants.h:10:19: error: expected unqualified-id before numeric constant #define STATUS 0x00 //Status Control Register 0
^~~~
C:\Users\mz\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5/tools/sdk/esp32/include/esp_rom/include/esp32/rom/ets_sys.h:644:3: note: in expansion of macro 'STATUS'
} STATUS;
In order to advise you on a solution, I would need to see your sketch code. Please follow these instructions
Select Tools > Auto Format from the Arduino IDE menus. This will make it easier for you to spot bugs and make it easier for us to read.
Select Edit > Copy for Forum from the Arduino IDE menus.
In a forum reply here, click on the post composer field.
Press Ctrl+V. This will paste the sketch to the post composer.
Move the cursor outside of the code tags before you add any additional text to your reply.
Repeat the above process if your sketch has multiple tabs.
Please also tell us how we can get the "ADS1256INO" library. Did you install it via the Library Manager? If so, tell us the full name of the library as it is shown in Library Manager. If not, provide the link to where you downloaded it from.
Click the Reply button to post your reply.
When your code requires a library that's not included with the Arduino IDE please post a link to where you downloaded that library from or if you installed it using Library Manager (Sketch > Include Library > Manage Libraries in the Arduino IDE) then say so and state the full name of the library.
Thank's i would probably never have guessed. I'll try to rename that variable or something and try again. for the ino library it's basically the ads1256 library available on github for teensy or arduino that i have reorganised in the form of a c++ class in order to hide implementation.
You are welcome. I'm glad if I was able to be of assistance.
As far as the fix goes, I'll share a couple of techniques that can be helpful to avoid collisions in general (I can't provide specific advice without being able to look at the code):
If a macro is used only internally in a header file, #undef the macro at the end of the file (or at whatever point in the file after which it will no longer be needed:
#undef STATUS
This limits the scope of the macro to the area between the #define and the #undef
Use a prefix to create a "namespace" for the macro. For example, ADS1256INO_STATUS is unlikely to be used outside the library.