Commit 8c61f81b authored by Tom Lane's avatar Tom Lane

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.
parent 37b61a69
#!/bin/sh #!/bin/sh
# Check all include files in or below the current directory for C++ # Check all exported PostgreSQL include files for C++ compatibility.
# compatibility. Typically, run this in PostgreSQL's src/include/ directory. # Run this from the top-level source directory after performing a build.
# No output if everything is OK, else compiler errors. # No output if everything is OK, else compiler errors.
set -e
me=`basename $0` me=`basename $0`
trap 'rm -rf $tmp' 0 1 2 3 15
tmp=`mktemp -d /tmp/$me.XXXXXX` tmp=`mktemp -d /tmp/$me.XXXXXX`
{ trap 'rm -rf $tmp' 0 1 2 3 15
echo ' extern "C" {'
echo '#include "postgres.h"'
# Omit port/, because it's platform specific, and c.h includes the relevant # Omit src/include/port/, because it's platform specific, and c.h includes
# file anyway. # the relevant file anyway.
# Omit regex/ and snowball/, because those files came from elsewhere, and # rusagestub.h is also platform-specific, and will be included by
# they would need extra work if someone cared to fix them. # utils/pg_rusage.h if necessary.
# gram.h will be included by ./parser/gramparse.h. # regex/regerrs.h is not meant to be included standalone.
# kwlist.h is not meant to be included without having defined PG_KEYWORD. # parser/gram.h will be included by parser/gramparse.h.
# rusagestub.h will be included by ./utils/pg_rusage.h if necessary. # parser/kwlist.h is not meant to be included standalone.
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,^\./,,'` for f in `find src/include src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-events.h -name '*.h' -print | \
echo "#include \"$f\"" grep -v -e ^src/include/port/ \
-e ^src/include/rusagestub.h -e ^src/include/regex/regerrs.h \
-e ^src/include/parser/gram.h -e ^src/include/parser/kwlist.h`
do
{
echo ' extern "C" {'
echo '#include "postgres.h"'
echo "#include \"$f\""
echo '};'
} >$tmp/test.cpp
# -fno-operator-names omits the definition of bitand and bitor, which
# collide with varbit.h. Could be fixed, if one were so inclined.
${CXX:-g++} -I . -I src/include -fsyntax-only -fno-operator-names -Wall -c $tmp/test.cpp
done 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment