Shop OBEX P1 Docs P2 Docs Learn Events
Constructor causing undefined reference to `___gxx_personality_sj0' — Parallax Forums

Constructor causing undefined reference to `___gxx_personality_sj0'

DavidZemonDavidZemon Posts: 2,973
edited 2015-01-23 16:08 in Propeller 1
I'm using the new operator as defined in SRLM's libpropeller. I have a constructor like so:
MyClass (const MyOtherClass *driver) : m_driver(driver), m_var(driver->get_var()) {}

And linking fails with
undefined reference to `___gxx_personality_sj0'

If I change the initialization of m_var to something else, like an integer literal, all is good. I can get around this issue in a similar fashion to the pure virtual function code bloat, by defining an empty function for __gxx_personality_sj0(). Does anyone know if this will cause serious issues at runtime? I'm guessing it has to do with exception handlers of some sort???

Comments

  • Heater.Heater. Posts: 21,230
    edited 2015-01-23 07:17
    I can't remember exactly and this could be totally wrong but it sounds like the kind of error that is fixed by:

    a) Compiling with g++ instead of c++. (propeller-elf-g++ or whatever it is called)

    or

    b) Adding the option -lstdc++ to the end of the linker invocation line.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-01-23 07:26
    Linking with stdc++ would probably "fix" the problem but also introduce another (code bloat). I guess I should have phrased the question as "what are the side effects of defining this function in such a way?"
  • Heater.Heater. Posts: 21,230
    edited 2015-01-23 14:40
    SwimDude

    Did you actually try that? Did the code then compile? Did it run?

    Does this code compile and run on other machines, Linux perhaps?

    I guess we might need to see the whole code to get an idea. I don't see a function being defined in any way only the beginnings of a class definition.
  • Heater.Heater. Posts: 21,230
    edited 2015-01-23 14:50
    Why are you using the redefinition of "new" as provided by the header file in the link you gave in the first post?
    That seems to be in a test directory, i.e. not for general use.
    Why not just us the normal "new"?

    Why don't any of the documentation links in the readme/front page work at https://github.com/DavidZemon/PropWare ?
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-01-23 16:08
    heater wrote:
    Why are you using the redefinition of "new" as provided by the header file in the link you gave in the first post?
    That seems to be in a test directory, i.e. not for general use.
    Why not just us the normal "new"?
    During real use I would expect a user to statically allocate objects, not use new/delete. For testing purposes though, using new and delete works much better and allows me to use setup and teardown functions.
    heater wrote:
    Why don't any of the documentation links in the readme/front page work at https://github.com/DavidZemon/PropWare ?
    I had a choice between functional links on the Doxygen page or functional links on github - both wasn't an option :(
    So, the links on http://david.zemon.name/PropWare should all work correctly.
    heater wrote:
    SwimDude

    Did you actually try that? Did the code then compile? Did it run?

    Does this code compile and run on other machines, Linux perhaps?

    I guess we might need to see the whole code to get an idea. I don't see a function being defined in any way only the beginnings of a class definition.
    Sorry - I thought I committed this code days ago but apparently not. The constructor in question can be found in the release-2.0-nightly branch in fatfs.h
Sign In or Register to comment.