[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] maint: use pragma consistently across replacement header
Re: [PATCH 2/2] maint: use pragma consistently across replacement headers
Fri, 26 Mar 2010 08:43:35 -0600
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:184.108.40.206) Gecko/20100301 Fedora/3.0.3-1.fc12 Lightning/1.0b1 Thunderbird/3.0.3
On 03/25/2010 06:46 PM, Bruno Haible wrote:
>> -#ifndef _GL_CTYPE_H
>> #if __GNUC__ >= 3
>> +#ifndef _GL_CTYPE_H
>> /* Include the original <ctype.h>. */
>> /* The include_next requires a split double-inclusion guard. */
>> address@hidden@ @NEXT_CTYPE_H@
> Did you know that GCC has a special optimization for include files? It
> recognizes the idiom that the file starts with a
> #ifndef FOO
> directive and ends with the corresponding
> directive. When the file is then #included a second time and FOO is
> defined, GCC skips the file entirely: it is not parsed again.
> You find this implemented in gcc-4.4.3/libcpp/files.c (field 'cmacro')
> and gcc-4.4.3/libcpp/directives.c (field 'mi_cmacro'). This optimization
> exists in GCC for a long time.
> I find it sad that patch destroys this optimization without a very good
Well, we could revert this patch, and instead patch fcntl.in.h,
stdlib.in.h, and so forth to follow this optimization. Or are you
saying that the optimization is useless for those files, because they
are split includes, and thus already fail to meet the pattern that gcc
is looking for?
Patch 1/2 is necessary; without it mingw compilation issues a warning.
But arpa_inet.in.h is also a split include.
Maybe it's worth a bug report to the gcc folks to get them to also
recognize idempotent preprocessor directives (such as the hoisted
#pragma) that do not affect the optimization of reparsing the file?
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
Description: OpenPGP digital signature