[Libvir] [PATCH] #include "config.h" needed

There is one file missing: #include "config.h" which ought to be included at the beginning of every C file. If missing, it causes problems on Windows -- in particular the C99 keyword 'restrict' won't be recognised and that causes compile errors all over the place. I've also changed a few <config.h> --> "config.h", which I think is more correct because config.h is a local file and should never come from the system include files (CC'd to Jim Meyering -- is this right in your opinion?) Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

On Thu, Jan 03, 2008 at 03:13:37PM +0000, Richard W.M. Jones wrote:
There is one file missing:
#include "config.h"
which ought to be included at the beginning of every C file. If missing, it causes problems on Windows -- in particular the C99 keyword 'restrict' won't be recognised and that causes compile errors all over the place.
Ok.
I've also changed a few <config.h> --> "config.h", which I think is more correct because config.h is a local file and should never come from the system include files (CC'd to Jim Meyering -- is this right in your opinion?)
Yep, that sounds good. Dan -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

Hi Rich. Happy new year :) "Richard W.M. Jones" <rjones@redhat.com> wrote:
There is one file missing:
#include "config.h"
which ought to be included at the beginning of every C file. If missing, it causes problems on Windows -- in particular the C99 keyword 'restrict' won't be recognised and that causes compile errors all over the place.
Yes, indeed. I like to use a "make distcheck"-time check for this. Just grep all version-controlled .c files, with a list of exceptions. Otherwise, it's too easy to forget.
I've also changed a few <config.h> --> "config.h", which I think is more correct because config.h is a local file and should never come from the system include files (CC'd to Jim Meyering -- is this right in your opinion?)
I used to prefer "config.h", too, but after some discussion many years ago, I switched, and now coreutils, gnulib, etc. use <config.h> everywhere. The "Configuration Header Files" section of the autoconf manual explains the subtle preference for <config.h>. All it takes is being burned once by a stray config.h file built for another architecture or with different options, and you'll never use "config.h" again :-)

Jim Meyering wrote:
I used to prefer "config.h", too, but after some discussion many years ago, I switched, and now coreutils, gnulib, etc. use <config.h> everywhere.
Do you also prefer to defend with #ifdef HAVE_CONFIG_H / #endif around each one, or does it not matter? I'll take a look at adding a make distcheck rule later, thanks. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim Meyering wrote:
I used to prefer "config.h", too, but after some discussion many years ago, I switched, and now coreutils, gnulib, etc. use <config.h> everywhere.
Do you also prefer to defend with #ifdef HAVE_CONFIG_H / #endif around each one, or does it not matter?
I avoid #ifdef HAVE_CONFIG_H, since that #ifdef is useful only in a .c file that might be compiled by a project with no config.h file.
I'll take a look at adding a make distcheck rule later, thanks.
Here's what I use in coreutils/Makefile.maint: [you can list the names of exceptions in the file, .x-sc_require_config_h] # This is reported not to work with make-3.79.1 # ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) ME := Makefile.maint CVS_LIST = build-aux/vc-list-files CVS_LIST_EXCEPT = \ $(CVS_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi # Nearly all .c files must include <config.h>. sc_require_config_h: @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \ grep -L '^# *include <config\.h>' \ $$($(CVS_LIST_EXCEPT) | grep '\.c$$') \ | grep . && \ { echo '$(ME): the above files do not include <config.h>' \ 1>&2; exit 1; } || :; \ else :; \ fi
participants (3)
-
Daniel P. Berrange
-
Jim Meyering
-
Richard W.M. Jones