pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: vignesh C <vignesh21@gmail.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: Unused header file inclusion
Date: Sun, 18 Aug 2019 14:37:34 -0400
Message-ID: <17463.1566153454@sss.pgh.pa.us> (raw)
In-Reply-To: <20190816230716.jndus364yfcz4sr6@alap3.anarazel.de>
References: <20190731203607.GA5260@alvherre.pgsql>
	<22389.1564606531@sss.pgh.pa.us>
	<20190731215314.tdlrqdgnd73do2ht@alap3.anarazel.de>
	<29534.1564615501@sss.pgh.pa.us>
	<20190803193733.g3l3x3o42uv4qj7l@alap3.anarazel.de>
	<20190816230716.jndus364yfcz4sr6@alap3.anarazel.de>

Andres Freund <andres@anarazel.de> writes:
> I've pushed the other ones.

Checking whether header files compile standalone shows you were overly
aggressive about removing fmgr.h includes:

In file included from /tmp/headerscheck.Ss8bVx/test.c:3:
./src/include/utils/selfuncs.h:143: error: expected declaration specifiers or '...' before 'FmgrInfo'
./src/include/utils/selfuncs.h:146: error: expected declaration specifiers or '...' before 'FmgrInfo'
./src/include/utils/selfuncs.h:152: error: expected declaration specifiers or '...' before 'FmgrInfo'

That's with a script I use that's like cpluspluscheck except it tests
with plain gcc not g++.  I attached it for the archives' sake.

Oddly, cpluspluscheck does not complain about those cases, but it
does complain about

In file included from /tmp/cpluspluscheck.FgX2SW/test.cpp:4:
./src/bin/scripts/scripts_parallel.h:18: error: ISO C++ forbids declaration of 'PGconn' with no type
./src/bin/scripts/scripts_parallel.h:18: error: expected ';' before '*' token
./src/bin/scripts/scripts_parallel.h:29: error: 'PGconn' has not been declared

(My headerscheck script is missing that header; I need to update it to
match the latest version of cpluspluscheck.)

			regards, tom lane

Attachments:

  [text/x-shellscript] headerscheck (1.7K, ../17463.1566153454@sss.pgh.pa.us/2-headerscheck)
  download | inline:
#!/bin/sh

# Check all exported PostgreSQL include files for standalone build.

# Run this from the top-level source directory after performing a build.
# No output if everything is OK, else compiler errors.

me=`basename $0`

tmp=`mktemp -d /tmp/$me.XXXXXX`

trap 'rm -rf $tmp' 0 1 2 3 15

# This should match what configure chooses, though we only care about -Wxxx
CFLAGS="-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -D_GNU_SOURCE -I . -I src/include -I src/interfaces/libpq $CFLAGS"

# Omit src/include/port/, because it's platform specific, and c.h includes
# the relevant file anyway.
# rusagestub.h is also platform-specific, and will be included by
# utils/pg_rusage.h if necessary.
# access/rmgrlist.h is not meant to be included standalone.
# regex/regerrs.h is not meant to be included standalone.
# parser/gram.h will be included by parser/gramparse.h.
# parser/kwlist.h is not meant to be included standalone.
# pg_trace.h and utils/probes.h can include sys/sdt.h from SystemTap,
# which itself contains C++ code and so won't compile with a C++
# compiler under extern "C" linkage.

for f in `find src/include src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-events.h -name '*.h' -print | \
    grep -v -e ^src/include/port/ \
	-e ^src/include/rusagestub.h -e ^src/include/regex/regerrs.h \
	-e ^src/include/access/rmgrlist.h \
	-e ^src/include/parser/gram.h -e ^src/include/parser/kwlist.h \
	-e ^src/include/pg_trace.h -e ^src/include/utils/probes.h`
do
	{
	    test $f != "src/include/postgres_fe.h" && echo '#include "postgres.h"'
	    echo "#include \"$f\""
	} >$tmp/test.c

	${CC:-gcc} $CFLAGS -c $tmp/test.c -o $tmp/test.o
done

view thread (30+ messages)  latest in thread

Message-ID: <17463.1566153454@sss.pgh.pa.us>
Permalink:  ../17463.1566153454@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17463.1566153454@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, alvherre@2ndquadrant.com, vignesh21@gmail.com
  Subject: Re: Unused header file inclusion
  In-Reply-To: <17463.1566153454@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox