Re: C is too old? opinions?



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,
Ian Collins <ian-news@xxxxxxxxxxx> said:

I like to have namespaces and using... ;)

So what's the difference in typing
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
.



Relevant Pages

  • Re: C is too old? opinions?
    ... you may very well end up in trouble typing that. ... _ or an UPPERCASE letter is the implementation's namespace). ... And no need for a trailing underscore at all. ... header guards should have a unique format that is not ...
    (comp.lang.c)
  • Re: Extending the LaTeX Namespace
    ... , dash, and digits as part of macro names. ... is not a drop-in replacement for PerlTeX. ... Perl sends TeX lines of input, ... callback to add a namespace mechanism to LaTeX. ...
    (comp.text.tex)
  • Re: Newbie question on passing functions as arguments
    ... #' indicates that the name is in the function namespace. ... prefix in front of the LAMBDA form because that is how ... it is still in the variable namespace. ... elements of a run-time list value "plugged" into a macro. ...
    (comp.lang.lisp)
  • Re: C is too old? opinions?
    ... you may very well end up in trouble typing that. ... _ or an UPPERCASE letter is the implementation's namespace). ...
    (comp.lang.c)
  • Re: Hungarian notation pros vs cons
    ... be in a different namespace than Employee. ... typing, but only when you declare the object or are tryign to cast it. ...
    (microsoft.public.dotnet.languages.csharp)