Re: huffman encoder



Martin Vejnar wrote:
Flash Gordon wrote:
aarklon@xxxxxxxxx wrote:

that is a header file can be set up in the following lines

/*things.h*/

#ifndef _THINGS__H_
>>>  #define _THINGS_H_
>>>  /*rest of include file*/
>>> #endif

People may do this, but it is definitely and categorically WRONG. All identifiers starting with an underscore followed by an upper case letter are reserved for the implementation. You should not ever use them unless you are using some implementation specific extension and the documentation for your implementation EXPLICITLY tells you to use one, and then you should only use it as your implementation says and reallise that the code is completely non-portable.

I agree that using underscore at the beginning of anything is a bad idea. But I think that the Standard actually neither prohibits nor discourages this.

I don't have the latest version of the Standard or I might have
 interpreted it incorrectly, so it is fairly possible that I'm
wrong. If that's the case, please prove me wrong. All quotations
of the Standard are from "Committee Draft - August 3, 1998".

The Standard clearly distinguishes between `identifier`s and
`macro name`s. What you're reffering to is actually not an
identifier. It's a macro name.

[7.1.3 #1] -- All  identifiers  that  begin  with  an
underscore and either an uppercase letter or  another
underscore  are always reserved for any use. -- All  identifiers
that  begin  with  an  underscore are always reserved for use as
identifiers with file scope in both the ordinary and tag name
spaces.

So yes, the Standard indeed marks these *identifiers* as
reserved. There is no such clause for macro names except the
following:

[6.10.8] [#4] None of these macro names(1), nor the identifier
defined, shall be the subject of a #define or a #undef
preprocessing directive.  Any other predefined  macro  names
shall  begin with a leading underscore followed by an uppercase
letter or a second underscore.

From N869, clearly contradicting your assertion above:

  6.2  Concepts

  6.2.1  Scopes of identifiers

  [#1]  An  identifier can denote an object; a function; a tag
  or a member of a structure, union, or enumeration; a typedef
  name; a label name; a macro name; or a macro parameter.  The
  same identifier can denote different entities  at  different
  points in the program.  A member of an enumeration is called
  an enumeration constant. Macro names  and  macro  parameters
  are  not  considered  further  here,  because  prior  to the
  semantic phase of program  translation  any  occurrences  of
  macro   names  in  the  source  file  are  replaced  by  the
  preprocessing token sequences that  constitute  their  macro
  definitions.

--
 Some informative links:
   news:news.announce.newusers
   http://www.geocities.com/nnqweb/
   http://www.catb.org/~esr/faqs/smart-questions.html
   http://www.caliburn.nl/topposting.html
   http://www.netmeister.org/news/learn2quote.html

.



Relevant Pages

  • Re: huffman encoder
    ... All identifiers starting with an underscore followed by an upper case letter are reserved for the implementation. ... The Standard clearly distinguishes between `identifier`s and `macro name`s. ... So that is clearly stating that a macro name is an identifier, so the reserving of identifiers later in the standard clearly includes macro names. ...
    (comp.lang.c)
  • Re: huffman encoder
    ... > I agree that using underscore at the beginning of anything is a bad ... But I think that the Standard actually neither prohibits nor ... > The Standard clearly distinguishes between `identifier`s and `macro ... avoid identifiers with leading underscores. ...
    (comp.lang.c)
  • Re: Using an instance of a struct as a member of that struct
    ... > seem to like to use identifiers with a leading underscore and ... > lowercase letter in macro replacement text (for user-written macros, ... underscore :-) the validity of the 'best practice' advice: ...
    (comp.lang.c)
  • Re: huffman encoder
    ... The above illustrates a very bad idea, using identifiers that begin ... Beginning identifiers with an underscore followed by an ... that is a header file can be set up in the following lines ... There is no header in standard C. ...
    (comp.lang.c)
  • Re: xmalloc.c - my xmalloc
    ... followed by an uppercase character or another underscore are reserved. ... All identifiers that begin with an underscore and either an uppercase ... there is an xmalloc session won't do anything */ ... Calling xmalloc_endin some "inner function" has the same damage ...
    (comp.lang.c)