Go Down

Topic: static String (Read 1 time) previous topic - next topic

stesmo

hello,
i get some errors if i put
Code: [Select]
static String test = "test";
into a basic arduino program:
undefined reference to `__cxa_guard_acquire'
undefined reference to `__cxa_guard_release'
undefined reference to `atexit'
without the static keyword everything is okay. is this behavior normal?
thanks
stesmo

Nick Gammon

Yeah, that obscure message is normal. You could move the string outside a function, then you won't get it. Or you can add this to near the top of your code:

Code: [Select]
// this blathering on is in case you want to make the class a static variable in a function
extern "C" {
  __extension__ typedef int __guard __attribute__((mode (__DI__)));
  int __cxa_guard_acquire(__guard *g) { return !*(char *)(g); };
  void __cxa_guard_release (__guard *g) { *(char *)g = 1; };
  void __cxa_guard_abort (__guard *) { };
} // end extern "C"
http://www.gammon.com.au/electronics

stesmo

hello,
thank you for the answer! i did simply move the string outside, easiest way to solve it.  XD

Go Up