On 7/4/07, Coockie_jr &lt;<a href="mailto:achille.talon@gmail.com">achille.talon@gmail.com</a>&gt; wrote:<br>&gt; <br>&gt; Hi!<br>&gt; I&#39;m currently wrapping a library and I&#39;m having some problems wth call<br>&gt; policies.
<br>&gt; Here is my peace of code that is causing an error.<br>&gt; <br>&gt; class A<br>&gt; {<br>&gt; public:<br>&gt; <br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; virtual char* toString() = 0;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; operator char*(){return toString();}
<br>&gt; };<br>&gt; <br>&gt; py++ gives me the following warning:<br>&gt; <br>&gt; <br>&gt; Warning: char* A::operator char*() [casting operator]<br>&gt; W1050 = The function returns &quot;%s&quot; type. You have to specify a call policies
<br>&gt; Be sure to take a look on Py++ defined call policies:<br>&gt; <a href="http://language-binding.net/pyplusplus/documentation/functions/call_policies.html#py-defined-call-policies">http://language-binding.net/pyplusplus/documentation/functions/call_policies.html#py-defined-call-policies
</a><br>&gt; <br>&gt; I checked the tutorials but I can&#39;t figure out how to define a call policy<br>&gt; for this case...<br><br>It depends on what you want:<br><br>* return Python string<br>&nbsp;&nbsp;- in this case exclude casting operator operator, change return type of toString from &quot;char*&quot; to &quot;const char*&quot; and you&#39;ll be fine. 
Boost.Python will expose the function using default call policies. If you cannot change code, than I suggest you to create small helper function:<br><br>std::string toString( const A&amp; a ){<br>&nbsp;&nbsp;&nbsp;&nbsp;return a.toString()<br>
}<br>&nbsp;&nbsp;<br>and register it instead of the A::toString function ( <a href="http://language-binding.net/pyplusplus/documentation/inserting_code.html">http://language-binding.net/pyplusplus/documentation/inserting_code.html</a>
 )<br><br>* If you want user to allow to write to this place, than you should use &quot;return_range&quot;( <a href="http://language-binding.net/pyplusplus/documentation/functions/call_policies.html#return-range">http://language-binding.net/pyplusplus/documentation/functions/call_policies.html#return-range
</a> ) call policies<br><br>HTH<br><br>-- <br>Roman Yakovenko<br>C++ Python language binding<br><a href="http://www.language-binding.net/">http://www.language-binding.net/</a>