<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><br><br><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">From: walter_bz@hotmail.com<br>To: rcsaba@gmail.com<br>Subject: RE: [cfe-dev] how to modify clang to allow bolt-on member functions?<br>Date: Sun, 21 Apr 2013 19:04:40 +0000<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}

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