aboutsummaryrefslogtreecommitdiff
path: root/src/tools/pginclude/cpluspluscheck
blob: b4ec64e25398e227692a3b90f46e3127dc7e79df (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
26
27
28
29
30
31
32
33
34
35
#!/bin/sh

# Check all include files in or below the current directory for C++
# compatibility.  Typically, run this in PostgreSQL's src/include/ directory.
# No output if everything is OK, else compiler errors.

set -e

me=`basename $0`

trap 'rm -rf $tmp' 0 1 2 3 15
tmp=`mktemp -d /tmp/$me.XXXXXX`

{
echo ' extern "C" {'
echo '#include "postgres.h"'

# Omit port/, because it's platform specific, and c.h includes the relevant
# file anyway.
# Omit regex/ and snowball/, because those files came from elsewhere, and
# they would need extra work if someone cared to fix them.
# gram.h will be included by ./parser/gramparse.h.
# kwlist.h is not meant to be included without having defined PG_KEYWORD.
# rusagestub.h will be included by ./utils/pg_rusage.h if necessary.
for file in `find . \( -name port -prune -o -name regex -prune -o -name snowball -prune \) -o -name '*.h' -not -name gram.h -not -name kwlist.h -not -name rusagestub.h -print`; do
	f=`echo $file | sed 's,^\./,,'`
	echo "#include \"$f\""
done

echo '};'
} >$tmp/test.cpp

# -fno-operator-names omits the definition of bitand and bitor, which would
# collide with varbit.h.  Could be fixed, if one were so inclined.
${CXX:-g++} -I. -fsyntax-only -fno-operator-names -Wall -c $tmp/test.cpp