[haiku-development] Re: Coding guidelines

  • From: Marcus Overhagen <marcusoverhagen@xxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 24 Jan 2008 18:18:14 +0100 (CET)

Bruno Albuquerque <bga@xxxxxxxxxxxxx> wrote:

> Salvatore Benedetto wrote:
> > For example, does all devs agree that private member _must_ start with
> > an underscore? Because it is not stated in the guidelines, but it looks to 
> > me

This is not correct. Private member variables must not start with an "_"
as all member variables must start with an "f". Only private functions 
can start with a _ and the coding guidlines have an example for that:

        private:
                int32 _PrivateMethod();
                int32 fMember1;

> > that some code does and some does not follow this guideline.

Some code was imported from other projects of the respective authors,
or might have been written before the coding guidelines were published.

The coding guidelines is a guidline, and does not require you to use
the _ for marking private functions. 

> 
> And this reminds me that, although our code guidelines does state that, 
> it is not a good practice and can lead to problems. For further 
> information, I recomend this link (via Web Archive):
> 
> http://web.archive.org/web/19990221004617/http://www.ses.com/~clarke/cpptips
> /_naming
> 
> -Bruno

Well, this is different. I'm pretty sure that a single underscore in global 
scope is reserved for the "system". We (Haiku) are providing the system, 
so it is save for us to use them (and they are not even in global scope)

Two consecutive underscore characters are reserved for use by the 
implementation,
this means compiler and library. (I think this is described somewhere in the 
C or C++ specification, but I couldn't find a reference right now).

That way, we can for example have for example a _printf in libbe.so
for internal use by the public printf, or the compiler could provide a 
"__declspec(dllexport)" attribute that should not collide with anything
that a user program uses, as long as the ordinary programmer doesn't
use the reserved namspace of _ and __


regards
Marcus

Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren
ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT FÜR ALLE NEUEINSTEIGER
Jetzt bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket
für clevere Doppel-Sparer, nur  29,95 Euro  inkl. DSL- und ISDN-Grundgebühr!
http://www.arcor.de/rd/emf-dsl-2

Other related posts: