[cfe-dev] add namespaces to C (in my local clang) OR "tag" a couple of functions

Don Quixote de la Mancha quixote at dulcineatech.com
Fri Oct 21 02:55:02 PDT 2011

I can understand now why you don't want to compile as C++.  But I
suggest you do it anyway from time to time, "When No One Is Looking".
Adding C-Style Casts won't hurt your C.  Several years down the road
you could surprise everyone that your C code suddenly builds as C++.

But a shorter-term possibility is that I understand CLang can be used
to edit C source code in various ways, for example to add
instrumentation for profilers.

Suppose you had the following C+Namespaces source:

namespace Foo {

int getFive( void )
   return 5;


After being preprocessed somehow it would look like:

/* Nothing here - the namespace declaration is gone */

int Foo_getFive( void )
   return 5;

/* Nothing here either */

You could then compile that is if it was regular C and not C++.

If your namespace declarations were replaced by blank lines, the line
numbers would still work right for source debuggers.

Don Quixote de la Mancha
Dulcinea Technologies Corporation
Software of Elegance and Beauty
quixote at dulcineatech.com

More information about the cfe-dev mailing list