-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
undefined reference to `__cxa_guard_acquire' - was: Template issues?! #1498
Comments
Is the "template" feature missing with the compiler the esp8266/Arduino is using? |
Come on... Anyone out there working with templates? |
A bunch of ESP8266 libraries use templates, like ESP8266WebServer and EEPROM, so I don't think there is a constraint from the compiler end. Perhaps you could point to the complete code you are trying to port? |
template are working on the esp8266 Arduino/libraries/EEPROM/EEPROM.h Lines 41 to 58 in 342c4ae
|
Thanks for feedback. The code I'm trying to port: https://github.com/KONNEKTING/KonnektingDeviceLibrary --> https://github.com/KONNEKTING/KonnektingDeviceLibrary/blob/master/KnxDevice.cpp#L239 As I said: I'm not a real c++ expert. Would be great if someone could give me a hint on what's wrong?! (even if this is not a topic for this issue-tracker) thanks a lot, Alex |
Had a bit time to further investigate... If I testwise remove the templates which use "unsigned char", I no longer get the duplicate-error. But:
This tells me: the template with the unsigned char type is missing ?! So, it has to do - somehow - with the unsigned char template. Any ideas? best regards, |
undefined reference to __cxa_guard_release is the problem here. |
Of course it's undefined, I commented out the template with the "unsigned char" type, but another code part still uses it.... All i wanted to show is: my templates are working, except the unsigned char type templates... The actual problem is, when I use the template with type "unsigned char", I get duplicate erors... See above. |
Steps to reproduce:
You will get error:
|
@Links2004 |
If I understood the linked issue correctly, one should not declare static variables and initialize them by a methode call at once. Problem is: I don't find such a "declare static and initialize by method call" constellation in my code. My code makes use of a static class instance to access the API of the library. I try to explain with some code snippets: From the header (of the library I try to port to ESP8266): The static instance of the main class of the library: public:
static KnxDevice Knx; // unique KnxDevice instance (singleton design pattern) The constructor itself is private, singleton-pattern... just use the static instance. // Constructor, Destructor
KnxDevice(); // private constructor (singleton design pattern)
~KnxDevice() {} // private destructor (singleton design pattern)
KnxDevice (const KnxDevice&); // private copy constructor (singleton design pattern) The user can then use the singleton to access the library: Knx.write(2, true ); The above shown "write" command is one of the templated-methods: template e_KnxDeviceStatus KnxDevice::write <boolean>(byte objectIndex, boolean value);
template e_KnxDeviceStatus KnxDevice::write <unsigned char>(byte objectIndex, unsigned char value);
template e_KnxDeviceStatus KnxDevice::write <char>(byte objectIndex, char value);
template e_KnxDeviceStatus KnxDevice::write <unsigned int>(byte objectIndex, unsigned int value);
template e_KnxDeviceStatus KnxDevice::write <int>(byte objectIndex, int value);
template e_KnxDeviceStatus KnxDevice::write <unsigned long>(byte objectIndex, unsigned long value);
template e_KnxDeviceStatus KnxDevice::write <long>(byte objectIndex, long value);
template e_KnxDeviceStatus KnxDevice::write <float>(byte objectIndex, float value);
template e_KnxDeviceStatus KnxDevice::write <double>(byte objectIndex, double value); So, I don't see the same case explained in issue #500, but according to the latest build error (fixed some other smaller things, the duplicate is now gone), it's somehow related to this issue:
So I'm still lost :-( p.s. the duplicate error mentioned at the beginning is gone, if I add "-fpermissive" (which I found at the end of the error message as a hint) to the gcc call. Required me to modify platform.txt a bit:
|
Both issues fixed: the guard issue is fixed by a PR and the duplicate error is fixed by changing one template from type "boolean" to "bool". |
tuxedo0801 can you explain how you fixed this? I replaced all the boolean to bool in KnxDevice.cpp and KnxDevice.h. But i don't really understand the "the guard issue is fixed by a PR" part. |
The actual issue was already discussed here: #500 And @iggr fixed this about 18 days ago: c62858f But there is no release that contains this bugfix. I guess it will be available soon: https://github.com/esp8266/Arduino/releases Look forward for release 2.1.0-RC3 or final 2.1.0 ... |
Hi there,
I'm not a real C++ expert, but trying to port a arduino library to esp8266/Arduino... (working with Arduino IDE 1.6.6 on Debian Linux 8 arm64 and 2.1.0-rc2 via boardmanager)
I thought doing a #ifdef here and there would do it. But now I'm struggling with this issue:
When compiling, I get the following error:
And that's the corresponding KnxDevice.cpp (line 235-243):
and the related snippet from the header file:
Of course it's a kind of duplicate, but with a different type flavor.
With arduino board the code compiles fine.
Any hints on this?
The text was updated successfully, but these errors were encountered: