[SVN] r9542 (C)

Rasmus Andersson rasmus at flajm.se
Mon May 12 07:03:44 UTC 2008


On 8 maj 2008, at 22.20, Allan Odgaard wrote:
> • change to use a UUID instead of _FILENAME_
>
> Our previous macro name was in disagreement with C/C++ naming  
> conventions¹.
>
> I searched for a convention for include guards and found this in the  
> C++ FAQ:
>
>    […] It is recommended to add some project unique part, and
>    if you are using a directory hierarchy also that, e.g.
>    MYPROJ_BAR_FOO_HPP if it resides in bar/foo.hpp
>
> I considered this, i.e. using the full path, but ended up with the  
> UUID since that is bullet-proof and looks consistent. The FAQ’s  
> suggested solution is still only a heuristic, adds about the same  
> noise as a UUID, the path of the file may likely change throughout  
> the life of it, and project name is not always known.
>
> The downside is of course that the macro name is nonsensical if part  
> of compiler output or similar.

I would argue <capitalized filename replace . with _> is more or less  
standard and don't interfere with naming conventions. i.e:

#ifndef MY_PROGRAM_H
#define MY_PROGRAM_H
...
#endif

On the other hand, it's not very often you need to read it and rarely  
makes any practical use in debugging.

>
>
> I am interested in feedback on this change — I’ve wanted to change  
> the generated name for a long time, but lack of a good convention  
> has made me delay it.
>
> ¹ Names beginning with double underscore or an underscore and a  
> capital letter are reserved for implementation (compiler, standard  
> library) and should not be used.
>
> Changed:
> U   trunk/Bundles/C.tmbundle/Snippets/Include header once only  
> guard.plist
>
> _______________________________________________
> textmate-dev mailing list
> textmate-dev at lists.macromates.com
> http://lists.macromates.com/mailman/listinfo/textmate-dev




More information about the textmate-dev mailing list