header in header files 
Author Message
 header in header files

   Most .h files contains a header like the following:

#ifndef _STDIO_H
# define _STDIO_H       1
....

Is there any tool  to generate this header  automatically from a plain
header file?  



Mon, 18 Jul 2005 13:05:27 GMT  
 header in header files

wrote in comp.lang.c:

Quote:

>    Most .h files contains a header like the following:

> #ifndef _STDIO_H
> # define _STDIO_H  1
> ....

> Is there any tool  to generate this header  automatically from a plain
> header file?  

Actually only header files should have macros using that format.  The
C language standard reserves all symbols beginning with two
underscores in a row, or an underscore followed by an upper case
letter, for the implementation, that is the compiler.

You should provide include guards in header files that you write
yourself, but if you are going to write a file named, for example,
header.h, how hard is it to write these two lines at the top:

#ifndef HEADER_H
#define HEADER_H

...then add the contents of your header, and a final line at the
bottom:

#endif

If that is really too much trouble, just think how hard it is going to
be to get the rest of the contents, in between those lines, right.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq



Mon, 18 Jul 2005 13:44:06 GMT  
 header in header files

Quote:


> wrote in comp.lang.c:

>>    Most .h files contains a header like the following:

>> #ifndef _STDIO_H
>> # define _STDIO_H     1
>> ....

>> Is there any tool  to generate this header  automatically from a plain
>> header file?  

> Actually only header files should have macros using that format.  The
> C language standard reserves all symbols beginning with two
> underscores in a row, or an underscore followed by an upper case
> letter, for the implementation, that is the compiler.

> You should provide include guards in header files that you write
> yourself, but if you are going to write a file named, for example,
> header.h, how hard is it to write these two lines at the top:

> #ifndef HEADER_H
> #define HEADER_H

If you switch to using:

#ifndef H_HEADER_
#define H_HEADER_

then you'll be able to create header files starting with the letter E.

        - Kevin.



Mon, 18 Jul 2005 14:44:41 GMT  
 header in header files

wrote in comp.lang.c:

Quote:


> > wrote in comp.lang.c:

> >>    Most .h files contains a header like the following:

> >> #ifndef _STDIO_H
> >> # define _STDIO_H     1
> >> ....

> >> Is there any tool  to generate this header  automatically from a plain
> >> header file?  

> > Actually only header files should have macros using that format.  The
> > C language standard reserves all symbols beginning with two
> > underscores in a row, or an underscore followed by an upper case
> > letter, for the implementation, that is the compiler.

> > You should provide include guards in header files that you write
> > yourself, but if you are going to write a file named, for example,
> > header.h, how hard is it to write these two lines at the top:

> > #ifndef HEADER_H
> > #define HEADER_H

> If you switch to using:

> #ifndef H_HEADER_
> #define H_HEADER_

> then you'll be able to create header files starting with the letter E.

>    - Kevin.

Good point.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq



Thu, 21 Jul 2005 15:34:40 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. C Header files including header files, mutually referencing typedefs

2. STL header files vs non-STL header files

3. Header files shall not #include any other headers

4. #ifndef/#ifdef problems in my header file (conditional header inclusion)

5. Including headers in headers

6. New C++ headers Vrs Old C++ headers.

7. Including headers inside headers

8. Wasted I/O when headers include other headers

9. WMF Header Scale ratio vs Aldus Header

10. problems using one header file for multiple source files

11. looking for a file list all functions in all header files

12. Fortran include file to C header file conversion

 

 
Powered by phpBB® Forum Software