Test __attribute__((constructor)) and __attribute__((destructor))

When using a global C++ object, the destructor isn't handled via
the .dtors section, but the destructor is set up with atexit() once
the constructor has been called.
This commit is contained in:
Martin Storsjö committed 2018-08-02 14:28:21 +03:00
1 parent 1ecc51f84d
commit 1836ed28dd
1 file changed
+8
+8
View File
@@ -30,6 +30,14 @@ public:
Hello global_h; Hello global_h;
__attribute__((constructor)) static void attr_ctor(void) {
printf("attr_ctor\n");
}
__attribute__((destructor)) static void attr_dtor(void) {
printf("attr_dtor\n");
}
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
std::cout<<"Hello world C++"<<std::endl; std::cout<<"Hello world C++"<<std::endl;
return 0; return 0;