ESP32+ Arduino IDE 2.0

Hi

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;

Do you have any ideas what to change maybe ?

Best regards

A better location for this post is probably in the IDE 2.0 thread

I’m moving this post there

Thanks!

I guess all the programming wizards were scared off by the fact you are using Arduino IDE 2.0? It's the same language and compiler people!

The error is caused by a name collision between the STATUS macro defined in the "ADS1256INO" library:

#define STATUS 0x00 //Status Control Register 0

and the STATUS enum object declared in the ESP32 SDK:

typedef enum {
    OK = 0,
    FAIL,
    PENDING,
    BUSY,
    CANCEL,
} STATUS;

The macro is defined before the enum object, so the preprocessor replacement changes the SDK code to this:

typedef enum {
    OK = 0,
    FAIL,
    PENDING,
    BUSY,
    CANCEL,
} 0x00;

That is the cause of the error.

In order to advise you on a solution, I would need to see your sketch code. Please follow these instructions

  1. 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.
  2. Select Edit > Copy for Forum from the Arduino IDE menus.
  3. In a forum reply here, click on the post composer field.
  4. Press Ctrl+V. This will paste the sketch to the post composer.
  5. Move the cursor outside of the code tags before you add any additional text to your reply.
  6. Repeat the above process if your sketch has multiple tabs.
  7. 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.
  8. 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.

Hi

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.

Best regards

Unbelievable, thanks sir!

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.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.