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

Ruben Van Boxem vanboxem.ruben at gmail.com
Fri Oct 21 01:51:38 PDT 2011


Op 21 okt. 2011 10:45 schreef "Jonas Gefele" <llvm.org at schrieb.de> het
volgende:
>
> Hi,
>
> thank you for your reply. Personally, I would prefer switching to C++ too.
> But it is unfortunately not possible :(
>
> I have been a little imprecise when I said "compability
> with real world C does not matter in my case". I meant this on a
> naming/linkage level (as we can handle this in our linker).

Would this not be a worthy extension to be supported? I know overloaded
functions can be enabled in GNU mode. It would make this a bit more
portable, if not very useful for other developers...

Ruben

>
> We have a big C code base and need source level compability (to the
> greatest possible extent). Introducing two new keywords "namespace" and
> "using" would not hurt much. But needing to fix tons of "void-pointer
> assignments" like:
>
>   char* x = malloc(100);
>   char* y = malloc(100);
>   char* z = malloc(100);
>
> would hurt a lot.
>
>
> Cheers,
> Jonas
>
> > 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
> >
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111021/3bb5bb04/attachment.html>


More information about the cfe-dev mailing list