8000 Cannot construct an object as a static variable in a function · Issue #207 · rsta2/circle · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Cannot construct an object as a static variable in a function #207
Closed
@leiradel

Description

@leiradel

I have a function to create a singleton of a class, but the linker complains about some missing functions.

lrcpp::Frontend& lrcpp::Frontend::getInstance() {
    static uint8_t fsmMemory[sizeof(CoreFsm)] alignas(CoreFsm);
    static Frontend singleton(fsmMemory);

    return singleton;
}
$ make clean && make
  CLEAN  /home/leiradel/Develop/circle/sample/libretro
  CPP   frontend/Main.o
  CPP   frontend/Kernel.o
  CPP   frontend/Frontend.o
  CPP   frontend/Fifo.o
  CC    core/main.o
  CPP   lrcpp/src/Components.o
  CPP   lrcpp/src/Core.o
  CPP   lrcpp/src/CoreFsm.o
  CPP   lrcpp/src/Frontend.o
  LD    kernel8.elf
aarch64-linux-gnu-ld: lrcpp/src/Frontend.o: in function `lrcpp::Frontend::getInstance()':
/home/leiradel/Develop/circle/sample/libretro/lrcpp/src/Frontend.cpp:65: undefined reference to `__cxa_guard_acquire'
aarch64-linux-gnu-ld: /home/leiradel/Develop/circle/sample/libretro/lrcpp/src/Frontend.cpp:65: undefined reference to `__cxa_guard_release'
make: *** [../../Rules.mk:155: kernel8.img] Error 1

These functions prevent the static variables from being initialized more than once should two threads try to get the singleton at the same time. I'm using an #idef to special case it when building with Circle, but I think it would be better if Circle supported it directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0