Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8c61f81

Browse files
committed
Rearrange cpluspluscheck to check just one .h file at a time.
This is slower than the original coding but avoids the problem of including files in an unpredictable order. Aside from being more trustworthy, we can get rid of some exclusions that were formerly made for what turn out to be ordering or re-inclusion problems. I also modified it to include libpq's exported files in the check. ecpg should be included as well, but I'm unclear on which ecpg .h files are meant to be included by clients.
1 parent 37b61a6 commit 8c61f81

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

src/tools/pginclude/cpluspluscheck

+26-25
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
#!/bin/sh
22

3-
# Check all include files in or below the current directory for C++
4-
# compatibility. Typically, run this in PostgreSQL's src/include/ directory.
3+
# Check all exported PostgreSQL include files for C++ compatibility.
4+
# Run this from the top-level source directory after performing a build.
55
# No output if everything is OK, else compiler errors.
66

7-
set -e
8-
97
me=`basename $0`
108

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

14-
{
15-
echo ' extern "C" {'
16-
echo '#include "postgres.h"'
11+
trap 'rm -rf $tmp' 0 1 2 3 15
1712

18-
# Omit port/, because it's platform specific, and c.h includes the relevant
19-
# file anyway.
20-
# Omit regex/ and snowball/, because those files came from elsewhere, and
21-
# they would need extra work if someone cared to fix them.
22-
# gram.h will be included by ./parser/gramparse.h.
23-
# kwlist.h is not meant to be included without having defined PG_KEYWORD.
24-
# rusagestub.h will be included by ./utils/pg_rusage.h if necessary.
25-
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
26-
f=`echo $file | sed 's,^\./,,'`
27-
echo "#include \"$f\""
13+
# Omit src/include/port/, because it's platform specific, and c.h includes
14+
# the relevant file anyway.
15+
# rusagestub.h is also platform-specific, and will be included by
16+
# utils/pg_rusage.h if necessary.
17+
# regex/regerrs.h is not meant to be included standalone.
18+
# parser/gram.h will be included by parser/gramparse.h.
19+
# parser/kwlist.h is not meant to be included standalone.
20+
21+
for f in `find src/include src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-events.h -name '*.h' -print | \
22+
grep -v -e ^src/include/port/ \
23+
-e ^src/include/rusagestub.h -e ^src/include/regex/regerrs.h \
24+
-e ^src/include/parser/gram.h -e ^src/include/parser/kwlist.h`
25+
do
26+
{
27+
echo ' extern "C" {'
28+
echo '#include "postgres.h"'
29+
echo "#include \"$f\""
30+
echo '};'
31+
} >$tmp/test.cpp
32+
33+
# -fno-operator-names omits the definition of bitand and bitor, which
34+
# collide with varbit.h. Could be fixed, if one were so inclined.
35+
${CXX:-g++} -I . -I src/include -fsyntax-only -fno-operator-names -Wall -c $tmp/test.cpp
2836
done
29-
30-
echo '};'
31-
} >$tmp/test.cpp
32-
33-
# -fno-operator-names omits the definition of bitand and bitor, which would
34-
# collide with varbit.h. Could be fixed, if one were so inclined.
35-
${CXX:-g++} -I. -fsyntax-only -fno-operator-names -Wall -c $tmp/test.cpp

0 commit comments

Comments
 (0)