Re: reasons for having no inclusion guards in config.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 8, Bob Friesenhahn <bfriesen@xxxxxxxxxxxxxxxxxxx> wrote:
> It is also interesting to note that it is usually ok for the
> content of the header file to be parsed any number of times.
> The only exception might be with some weird macro expansion
> (but that would be a bug).
>
> The conditional inclusion of content is only an optimization.

If you have a struct definition (C/C++) or a typedef (C) in the
.h file, C compilers may refuse to process it twice and an
inclusion guard is needed:

user@host # cat x.h
typedef int counter_t;

user@host # cat x.c
#include "x.h"
#include "x.h"
int main(void) { return 0; }

user@host # gcc x.c
In file included from x.c:2:
x.h:1: redefinition of `counter_t'
x.h:1: `counter_t' previously declared here

user@host # tcc x.c
x.h:1:  Error: duplicate typedef 'counter_t'
x.c: 0 warnings, 1 error, 0 serious errors

oki,

Steffen


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux