[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 00:43:14 PDT 2011


On Fri, Oct 21, 2011 at 12:33 AM, Jonas Gefele <llvm.org at schrieb.de> wrote:
> (In my local clang copy) I would like to add namespace support to C. I
> want to use it to "tag" a couple of functions like this:
>
> namespace tag1 {

> (In my local clang copy) I need the ability to "tag" a bunch of C/C++
> functions/globals with some "name". Something like:

Would it work to just compile your C sources with a C++ compiler?

/* Foo.c
 */

#ifdef __cplusplus
extern "C" {
#endif

#include "Foo.h"  /* These function names will not be mangled */

#ifdef __cplusplus
}
#endif

#ifdef __cplusplus
namespace tag1{
#endif

void foo( int bar )
{
  getDownAndBoogie();

  return;
}

#ifdef __cplusplus
} /* namespace tag1 */
#endif

Some creative macro definitions could make that look less ugly.




-- 
Don Quixote de la Mancha
Dulcinea Technologies Corporation
Software of Elegance and Beauty
http://www.dulcineatech.com
quixote at dulcineatech.com



More information about the cfe-dev mailing list