Debian Codegraph @

cmake/cxx_tests/dtor_after_atexit.cpp

raw
1 // DESCRIPTION
2 //
3 // Test to check whether the C++ compiler calls global destructors after atexit functions,
4 // define HAVE_DTOR_AFTER_ATEXIT. WARNING: If cross-compiling, the test
5 // cannot be performed, the default action is to define
6 // HAVE_DTOR_AFTER_ATEXIT.
7 // In sync with AC_CXX_DTOR_AFTER_ATEXIT (2008-04-12).
8 //
9 // COPYLEFT
10 //
11 // Copyright (c) 2009 Theo Papadopoulo <[email protected]>
12 // Copyright (c) 2008 Todd Veldhuizen
13 // Copyright (c) 2008 Luc Maisonobe <[email protected]>
14 //
15 // Copying and distribution of this file, with or without modification, are
16 // permitted in any medium without royalty provided the copyright notice
17 // and this notice are preserved.
18
19 #include <unistd.h>
20 #include <stdlib.h>
21
22 static int dtor_called = 0;
23 class A { public : ~A () { dtor_called = 1; } };
24 static A a;
25
26 void f() { _exit(dtor_called); }
27
28 int main (int , char **)
29 {
30 atexit (f);
31 return 0;
32 }