@@ -4,8 +4,52 @@ output=$(./simplecpp simplecpp.cpp -e -f 2>&1)
44ec=$?
55errors=$( echo " $output " | grep -v ' Header not found: <' )
66if [ $ec -ne 0 ]; then
7- # only fail if got errors which do not refer to missing system includes
7+ # only fail if we got errors which do not refer to missing system includes
88 if [ ! -z " $errors " ]; then
99 exit $ec
1010 fi
11- fi
11+ fi
12+
13+ if [ -z " $CXX " ]; then
14+ exit 0
15+ fi
16+
17+ cxx_type=$( $CXX --version | head -1 | cut -d' ' -f1)
18+ if [ " $cxx_type " = " Ubuntu" ]; then
19+ cxx_type=$( $CXX --version | head -1 | cut -d' ' -f2)
20+ fi
21+ if [ " $cxx_type " = " g++" ]; then
22+ gcc_ver=$( $CXX -dumpversion)
23+ ./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/x86_64-linux-gnu/c++/$gcc_ver "
24+ ec=$?
25+ if [ $ec -ne 0 ]; then
26+ exit $ec
27+ fi
28+ elif [ " $cxx_type " = " clang" ]; then
29+ clang_ver=$( $CXX -dumpversion)
30+ clang_ver=${clang_ver%% .* }
31+ find /usr/include -name features.h
32+ find /usr/include -name endian.h
33+ cxx_inc=" /usr/include/c++/v1"
34+ if [ ! -d " $cxx_inc " ]; then
35+ cxx_inc=" /usr/lib/llvm-$clang_ver /include/c++/v1"
36+ fi
37+ ./simplecpp simplecpp.cpp -e -f -std=gnu++11 -D__BYTE_ORDER__ -D__linux__ -I" $cxx_inc " -I" /usr/include"
38+ ec=$?
39+ if [ $ec -ne 0 ]; then
40+ exit $ec
41+ fi
42+ elif [ " $cxx_type " = " Apple" ]; then
43+ # clang_ver=$($CXX -dumpversion)
44+ # clang_ver=${clang_ver%%.*}
45+ find /Applications -name cctype
46+ # 16.1 is a Xcode version common to all used platforms
47+ ./simplecpp simplecpp.cpp -e -f -std=gnu++11 -D__BYTE_ORDER__ -D__APPLE__ -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"
48+ ec=$?
49+ if [ $ec -ne 0 ]; then
50+ exit $ec
51+ fi
52+ else
53+ echo " unknown compiler '$cxx_type '"
54+ exit 1
55+ fi
0 commit comments