1 # ctor.at -- Test constructors via C++ -*- Autotest -*-
3 # Copyright (C) 2007-2008, 2011-2019, 2021-2024 Free Software
5 # Written by Noah Misch, 2007
7 # This file is part of GNU Libtool.
9 # GNU Libtool is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
14 # GNU Libtool is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU Libtool; see the file COPYING. If not, a copy
21 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
22 # or obtained by writing to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 AT_BANNER([Constructors.])
28 AT_SETUP([C++ static constructors])
30 AT_KEYWORDS([libtool])
33 [[#define magic 0xaabbccdd
36 Foo() { bar = magic; }
53 return instance.bar != magic;
57 AT_CHECK([$LIBTOOL --tag=CXX --mode=compile $CXX $CPPFLAGS $CXXFLAGS \
58 -c libctor.cpp -o libctor.lo], [0], [ignore], [ignore])
59 AT_CHECK([$LIBTOOL --tag=CXX --mode=compile $CXX $CPPFLAGS $CXXFLAGS \
60 -c main.cpp -o main.lo], [0], [ignore], [ignore])
61 AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS \
62 libctor.lo -o libctor.la -rpath /none], [0], [ignore], [ignore])
63 AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS \
64 main.lo libctor.la -o main$EXEEXT], [0], [ignore], [ignore])
66 LT_AT_EXEC_CHECK([./main], [0])