[cfe-dev] FW: how to modify clang to allow bolt-on member functions?

walter lynsdale walter_bz at hotmail.com
Sun Apr 21 12:05:39 PDT 2013



From: walter_bz at hotmail.com
To: rcsaba at gmail.com
Subject: RE: [cfe-dev] how to modify clang to allow bolt-on member functions?
Date: Sun, 21 Apr 2013 19:04:40 +0000




oops - seems I posted the wrong example carelessly..
THIS is what i meant:-

#include <iostream>
struct Foo {
   int    x;  <<<< no declaration of Foo::bar() in the class
};
void Foo::bar() {//<<<<<< not declared in the class
   std::cout<<x;
}
int main(int argc,const char** argv){
  Foo    f;f.x=10;
  f.bar();
}

Its an "itch" I have from long running frustrations with C++, and seeing rust/go & reading that article makes me think i can't be alone in this.


> Date: Sun, 21 Apr 2013 10:51:11 +0200
> Subject: Re: [cfe-dev] how to modify clang to allow bolt-on member functions?
> From: rcsaba at gmail.com
> To: walter_bz at hotmail.com
> CC: cfe-dev at cs.uiuc.edu
> 
> Hi Walter,
> 
> On Sat, Apr 20, 2013 at 5:51 PM, walter lynsdale  wrote:
> > #include <iostream>
> > struct Foo {
> >     int    x;
> >     void bar();
> > };
> > void Foo::bar() {//<<<<<< not declared in the class
> >     std::cout<<x;
> > }
> > int main(int argc,const char** argv){
> >     Foo    f;f.x=10;
> >     f.bar();
> > }
> >
> >
> > Could anyone comment how difficult it would be to modify my own build of
> > clang to allow this to compile. (and provide pointers on which areas of the
> > source to look at)
> 
> I don't understand why you want to modify your compiler. This code
> compiles fine with both g++ 4.5.3 and clang++ 3.3 (trunk 178973)
> 
> $ g++ -Wall -pedantic -W bolt-on.cpp
> bolt-on.cpp:9:5: warning: unused parameter ‘argc’
> bolt-on.cpp:9:5: warning: unused parameter ‘argv’
> 
> $ clang++ -Wall -pedantic -W bolt-on.cpp
> bolt-on.cpp:9:14: warning: unused parameter 'argc' [-Wunused-parameter]
> int main(int argc,const char** argv){
>              ^
> bolt-on.cpp:9:32: warning: unused parameter 'argv' [-Wunused-parameter]
> int main(int argc,const char** argv){
>                                ^
> 2 warnings generated.
> 
> 
> Note that Foo::bar _is_ declared in the class (the "void bar();" line
> inside struct Foo declares a function Foo::bar).
> 
> Csaba
> -- 
> GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
> The Tao of math: The numbers you can count are not the real numbers.
> Life is complex, with real and imaginary parts.
> "Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
> "People disagree with me. I just ignore them." -- Linus Torvalds
 		 	   		   		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130421/6eda0a6d/attachment.html>


More information about the cfe-dev mailing list