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:
1 parent
1ecc51f84d
commit
1836ed28dd
1 file changed
+8
@@ -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;
|
||||||
|
|||||||
Reference in new issue
Block a user