[Ecls-list] How to wrap and return constant pointers with c-inline?

Dietrich Bollmann dietrich at formgames.org
Sun Jul 7 16:00:48 UTC 2013


Hi Peter,

On Mon, Jul 8, 2013 at 12:27 AM, Peter Enerccio <enerccio at gmail.com> wrote:

> Constness of a pointer, in c and c++ means absolutely nothing. It is just
> a way for programmer to self policy, same as private/public in c++/java,
> they are only for compilers to throw errors and programmers to avoid those
> errors. In memory, it is just data, and as data, in c you can force
> compiler to represent them in any way, ie cast. Anyways, glad to be help.
>

Interesting.  I thought that the compiler might treat memory different if
it cannot be manipulated and that in this case the const qualification
therefore is enforced by the compiler.

Thanks again for your help!

Dietrich


On Mon, Jul 8, 2013 at 12:27 AM, Peter Enerccio <enerccio at gmail.com> wrote:

> Constness of a pointer, in c and c++ means absolutely nothing. It is just
> a way for programmer to self policy, same as private/public in c++/java,
> they are only for compilers to throw errors and programmers to avoid those
> errors. In memory, it is just data, and as data, in c you can force
> compiler to represent them in any way, ie cast. Anyways, glad to be help.
>
>
> 2013/7/7 Dietrich Bollmann <dietrich at formgames.org>
>
>> On Sun, Jul 7, 2013 at 9:48 PM, ... <. <enerccio at gmail.com>..> wrote:
>>
>> Why cant you just cast it in the inline part? (void*) comes to mind...
>>>
>>
>> Because I thought that it is not possible to "cast away" a const
>> qualification...
>>
>> ...But you are completely right:  even if this might not be a good thing
>> to do under normal circumstances, it actually is possible and solves the
>> problem :)
>>
>> Thanks for the advice!
>>
>> Dietrich
>>
>>
>>
>> On Sun, Jul 7, 2013 at 8:52 PM, Dietrich Bollmann <dietrich at formgames.org
>> > wrote:
>>
>>> Hi,
>>>
>>> How can I wrap and return the constant pointer
>>>
>>>   const CRhinoCommandContext *context;
>>>
>>> with c-inline?
>>>
>>> Using something like
>>>
>>>   (ffi:c-inline () () :pointer-void "context" :one-liner t)
>>>
>>> results in the error
>>>
>>>   error C2664: 'ecl_make_foreign_data' : cannot convert parameter 3 from
>>> 'const CRhinoCommandContext *' to 'void *'
>>>         Conversion loses qualifiers
>>>
>>> But I couldn't find something like :const-pointer-void...
>>>
>>> How can I solve this problem?
>>>
>>> Thanks,
>>>
>>> Dietrich
>>>
>>>
>>
>
>
> --
> Bc. Peter Vaňušanik
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20130708/32a8dd3c/attachment.html>


More information about the ecl-devel mailing list