11#! /bin/sh
22
3+ set -x
4+
35output=$( ./simplecpp simplecpp.cpp -e -f 2>&1 )
46ec=$?
57errors=$( echo " $output " | grep -v ' Header not found: <' )
68if [ $ec -ne 0 ]; then
7- # only fail if got errors which do not refer to missing system includes
9+ # only fail if we got errors which do not refer to missing system includes
810 if [ ! -z " $errors " ]; then
911 exit $ec
1012 fi
11- fi
13+ fi
14+
15+ if [ -z " $CXX " ]; then
16+ exit 0
17+ fi
18+
19+ $CXX --version
20+ cxx_type=$( $CXX --version | head -1 | cut -d' ' -f1)
21+ if [ " $cxx_type " = " Ubuntu" ]; then
22+ cxx_type=$( $CXX --version | head -1 | cut -d' ' -f2)
23+ fi
24+ echo cxx_type=$cxx_type
25+ if [ " $cxx_type " = " g++" ]; then
26+ gcc_ver=$( $CXX -dumpversion)
27+ find /usr/include -name cctype
28+ find /usr/include -name c++config.h
29+ ./simplecpp simplecpp.cpp -e -f -std=gnu++11 -D__GNUC__ -D__STDC__ -D__STDC_HOSTED__ -D__CHAR_BIT__=8 -I" /usr/include" -I" /usr/include/linux" -I" /usr/include/c++/$gcc_ver " -I" /usr/include/c++/$gcc_ver /x86_64-pc-linux-gnu" -I" /usr/lib64/gcc/x86_64-pc-linux-gnu/$gcc_ver /include" -I" /usr/include/x86_64-linux-gnu/c++/$gcc_ver "
30+ ec=$?
31+ if [ $ec -ne 0 ]; then
32+ exit $ec
33+ fi
34+ elif [ " $cxx_type " = " clang" ]; then
35+ # clang_ver=$($CXX -dumpversion)
36+ # clang_ver=${clang_ver%%.*}
37+ find /usr/include -name cctype
38+ ./simplecpp simplecpp.cpp -e -f -std=gnu++11 -D__BYTE_ORDER__ -I" /usr/include/c++/v1"
39+ ec=$?
40+ if [ $ec -ne 0 ]; then
41+ exit $ec
42+ fi
43+ elif [ " $cxx_type " = " Apple" ]; then
44+ # clang_ver=$($CXX -dumpversion)
45+ # clang_ver=${clang_ver%%.*}
46+ find /Applications -name cctype
47+ # 16.1 is a Xcode version common to all used platforms
48+ ./simplecpp simplecpp.cpp -e -f -std=gnu++11 -I" /Applications/Xcode_16.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include" -I" /Applications/Xcode_16.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
49+ ec=$?
50+ if [ $ec -ne 0 ]; then
51+ exit $ec
52+ fi
53+ else
54+ echo " unknown compiler '$cxx_type '"
55+ exit 1
56+ fi
0 commit comments