B4R Question ArduinoBLE lib wrapping EMPTY issue

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

working to wrap the ArduinoBLE library to be used with an Arduino GIGA R1.

Getting this error when compiling a test sketch:
B4X:
Basic\B4R\Objects\src\rCore.h:614:40: error: expected unqualified-id before ';' token 614 | static B4RString* EMPTY; | ^ In file included from C:...

I confirmed the issue is caused by a macro named EMPTY coming from the Arduino GIGA (mbed / Zephyr / CMSIS) core.
Undefining EMPTY in B4RDefines.h is not sufficient, because the macro is reintroduced per translation unit by the Arduino core.

The only robust fix is to undefine EMPTY locally in rCore.h:
B4X:
// --- Fix macro collision with Zephyr / mbed ---
#ifdef EMPTY
  #undef EMPTY
#endif
static B4RString* EMPTY;
This keeps API compatibility and avoids renaming core symbols.

Another option would be to rename EMPTY to EMPTYSTR in rCore.h and rCore.cpp:
B4X:
static B4RString* EMPTYSTR;

static B4RString be_empty;
B4RString* B4RString::EMPTYSTR = be_empty.wrap("");

Is there another solution for this instead modifying the B4R rCore?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Another option would be to rename EMPTY to EMPTYSTR in rCore.h and rCore.cpp:
This will not work without updating B4R as the compiler emits code referencing this variable. I will change this variable name in the next update. For now you will need to modify rCore.h.
 
Upvote 0
Top