blob: 4ba091b91869bb85a1fbb087996bd63515f6a787 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/usr/bin/env bash
# A host includes term.h and nothing else. The header compiles alone as
# strict C11 and as C++, with only include/term on the include path.
set -euo pipefail
cd "${1:-$(dirname "$0")/..}"
cc=${CC:-cc}
cxx=${CXX:-c++}
status=0
echo '#include "term.h"' | "$cc" -std=c11 -Wall -Wextra -Wpedantic -Werror \
-Iinclude/term -x c -fsyntax-only - || { echo "term.h: not valid C11" >&2; status=1; }
if command -v "$cxx" >/dev/null; then
echo '#include "term.h"' | "$cxx" -std=c++17 -Wall -Wextra -Wpedantic -Werror \
-Iinclude/term -x c++ -fsyntax-only - || { echo "term.h: not valid C++" >&2; status=1; }
fi
# Apple headers define wide before a host includes the Unicode API.
unicode_header=$'typedef struct wide { int value; } wide;\n#include "unicode/width.h"'
echo "$unicode_header" | "$cc" -std=c11 -Wall -Wextra -Wpedantic -Werror \
-Iinclude/term -x c -fsyntax-only - || { echo "unicode/width.h: conflicts with host types" >&2; status=1; }
if command -v "$cxx" >/dev/null; then
echo "$unicode_header" | "$cxx" -std=c++17 -Wall -Wextra -Wpedantic -Werror \
-Iinclude/term -x c++ -fsyntax-only - || { echo "unicode/width.h: conflicts with C++ host types" >&2; status=1; }
fi
exit $status
|