c_mem_safety/construct_destruct.c

20 lines
339 B
C
Raw Normal View History

2025-04-24 18:19:47 +02:00
#include<stdio.h>
2025-04-24 18:22:20 +02:00
#include<stdlib.h>
2025-04-24 18:19:47 +02:00
void __attribute__((constructor)) calledFirst();
void __attribute__((destructor)) calledLast();
2025-04-24 18:22:20 +02:00
int main() {
2025-04-24 18:19:47 +02:00
printf("\nI am in main");
2025-04-24 18:22:20 +02:00
// return 0;
exit(0); // Even called on this!!!
2025-04-24 18:19:47 +02:00
}
void calledFirst() {
printf("\nI am called first");
}
void calledLast() {
printf("\nI am called last\n");
}