Re: C is too old? opinions?
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Tue, 25 Sep 2007 18:44:27 -0400
Jack Klein wrote:
On Wed, 12 Jul 2006 22:46:05 GMT, Andrew Poelstra
<apoelstra@xxxxxxxxxxxxx> wrote in comp.lang.c:
On 2006-07-12, Lasse Espeholt <Lasse> wrote:
On 2006-07-13 00:29:04 +0200,
Ian Collins <ian-news@xxxxxxxxxxx> said:
Lasse Espeholt wrote:
On 2006-07-13 00:19:03 +0200,So what's the difference in typing
Ian Collins <ian-news@xxxxxxxxxxx> said:
I like to have namespaces and using... ;)
a few includes or the equivalent using directives?
with includes you risk that the files
have functions there have the same name.
with includes you shall write
"ifndef __FILE_H__" otherwise you could end up in trouble.
Well, you may very well end up in trouble typing that. Invading the
implementation's namespace is a no-no. (Using _ followed by another
_ or an UPPERCASE letter is the implementation's namespace).
What exactly is wrong with typing this?:
#ifndef FILE_H_
#define FILE_H_
...
#endif
The problem with this is that you might have a file named something
like enter_data.h, and generate an identifier ENTER_DATA_H_, which
runs afoul of the pattern E<upper case letter> reserved for future
expansion of <errno.h>.
Better to swap around like this:
H_FILE
...because there are no reserved identifiers beginning with "H_" or
"h_". And no need for a trailing underscore at all.
I like the trailing underscore, because I think that the
header guards should have a unique format that is not
likely to be accidentally written in a non header guard macro.
When I had a file named sort.h, I tried a header guard H_SORT,
but there was a problem because the program also had macros like
B_SORT
I_SORT
S_SORT
Q_SORT
and of course: H_SORT
I kept my H_SORT macro for heapsort,
and changed some other things instead.
At this current time, I'm using H_filename_H.
--
pete
.
- Follow-Ups:
- Re: C is too old? opinions?
- From: Joachim Schmitz
- Re: C is too old? opinions?
- From: Keith Thompson
- Re: C is too old? opinions?
- References:
- Re: C is too old? opinions?
- From: Jack Klein
- Re: C is too old? opinions?
- Prev by Date: Re: Enums
- Next by Date: Re: ~ operator returns signed value
- Previous by thread: Re: [OT] Re: C is too old? opinions?
- Next by thread: Re: C is too old? opinions?
- Index(es):
Relevant Pages
|