[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

Re: macro conventions

Joel C. Salomon

5/13/2011 5:42:00 PM

On Friday, May 13, 2011 12:56:20 PM UTC-4, Bill Cunningham wrote:
> In defining macros it is of course proper style to use all caps for
> example:
>
> #define AVG 14

That is indeed a common style.

> There are other conventions too. <snip> For example:
>
> #define __FILE__
>
> Two underscores if front of and behind the define. And here:
>
> #define _GNU_SOURCE
>
> One underscore in front and no underscores at the end.

These conventions are for macros defined by the compiler. You should *never* define macros beginning with two underscores (e.g., __foo) or beginning with an underscore & an uppercase letter (e.g., _Foo).

Defining macros with names like these can have unpredictable results in your program. If you're running GCC, for example, the line

#define _GNU_SOURCE

tells the compiler that your program is not written in C at all, and GCC will change languages accordingly. (This newsgroup can only answer questions about C, not the other language.)

In short: Don't do this.

--Joel