header files

J

j0mbolar

out of curiosity, what conventions do you guys use for header files?

[1] include guards

[2] type definitions

[3] prototypes

[4] #defines

[5] end of include guard

I would like to see what most of you use to see what the common convention is.
 
E

Emmanuel Delahaye

In said:
out of curiosity, what conventions do you guys use for header files?

[1] include guards

[2] type definitions

[3] prototypes

[4] #defines

[5] end of include guard

I would like to see what most of you use to see what the common
convention is.

My personnal code generator makes that for headers:

#ifndef H_ED_HEADER_20040306204849
#define H_ED_HEADER_20040306204849

#ifdef __cplusplus
extern "C"
{
#endif

/* macros ============================================================== */
/* constants =========================================================== */
/* types =============================================================== */
/* structures ========================================================== */
/* internal public functions =========================================== */
/* entry points ======================================================== */
/* public variables ==================================================== */

#ifdef __cplusplus
}
#endif

#endif /* guard */

/* Guards added by GUARD (c) AETA 2000-2003 Jun 25 2003 Ver. 1.6 */
 
J

Joona I Palaste

Adrian de los Santos said:
out of curiosity, what conventions do you guys use for header files?

[1] include guards
Whats a guard ?

It's a preprocessor device to stop the same file from being #included
more than once. It looks something like this:

#ifndef GUARD
#include <foo.h>
#define GUARD
#endif


--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"'So called' means: 'There is a long explanation for this, but I have no
time to explain it here.'"
- JIPsoft
 
T

Thomas Matthews

j0mbolar said:
out of curiosity, what conventions do you guys use for header files?

[1] include guards
#ifndef H_MODULE_NAME
#define H_MODULE_NAME

[2] type definitions
struct Tag_Name
{
/* contents */
};
typedef struct Tag_Name Tag_Name;

[3] prototypes
void My_Function(unsigned int count,
const char * name);
[4] #defines
#define MAX_ROWS 6
#define MAX_COLUMNS 8
#define ASIC_CLEAR_BIT (1 << 4)u

[5] end of include guard
#endif /* H_MODULE_NAME */

I would like to see what most of you use to see what the common convention is.



--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
T

those who know me have no need of my name

in comp.lang.c i read:
out of curiosity, what conventions do you guys use for header files?

this has been discussed many times. how can you stand posting from google
but not using it's search feature? (which phenomena is hardly new either.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top