C Variadic Functions via UFFI?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

C Variadic Functions via UFFI?

Mariano Martinez Peck
Hi guys,

I am wondering if I can wrap some variadic functions (with optional arguments) with UFFI. Is this possible? If true, how so? For my particular use case, I am checking if I can call fcntl()
which has a third optional argument.

Thanks in advance,

--
Reply | Threaded
Open this post in threaded view
|

Re: C Variadic Functions via UFFI?

Andres Valloud-4
I wouldn't do that if I were you.  The manual says fcntl() can be a
macro, and you can't call a macro from an FFI.

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/fcntl.h.html

On 9/22/16 15:12 , Mariano Martinez Peck wrote:

> Hi guys,
>
> I am wondering if I can wrap some variadic functions (with optional
> arguments) with UFFI. Is this possible? If true, how so? For my
> particular use case, I am checking if I can call fcntl()
> which has a third optional argument.
>
> Thanks in advance,
>
> --
> Mariano
> http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: C Variadic Functions via UFFI?

EstebanLM
along with what Andres says, also no, you do not have support for variadic functions.
what you do this is to declare your functions as if they were non-variadic:

pritnf: format intValue:  number
        self ffiCall: #(int printf(String format, int number))

that will work… yes is not the best in the word, but it works :)

Esteban


> On 23 Sep 2016, at 08:11, Andres Valloud <[hidden email]> wrote:
>
> I wouldn't do that if I were you.  The manual says fcntl() can be a macro, and you can't call a macro from an FFI.
>
> http://pubs.opengroup.org/onlinepubs/009695399/basedefs/fcntl.h.html
>
> On 9/22/16 15:12 , Mariano Martinez Peck wrote:
>> Hi guys,
>>
>> I am wondering if I can wrap some variadic functions (with optional
>> arguments) with UFFI. Is this possible? If true, how so? For my
>> particular use case, I am checking if I can call fcntl()
>> which has a third optional argument.
>>
>> Thanks in advance,
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>


Reply | Threaded
Open this post in threaded view
|

Re: C Variadic Functions via UFFI?

Andres Valloud-4
The identifier printf() can also be a macro...

On 9/23/16 1:15 , Esteban Lorenzano wrote:

> along with what Andres says, also no, you do not have support for variadic functions.
> what you do this is to declare your functions as if they were non-variadic:
>
> pritnf: format intValue:  number
> self ffiCall: #(int printf(String format, int number))
>
> that will work… yes is not the best in the word, but it works :)
>
> Esteban
>
>
>> On 23 Sep 2016, at 08:11, Andres Valloud <[hidden email]> wrote:
>>
>> I wouldn't do that if I were you.  The manual says fcntl() can be a macro, and you can't call a macro from an FFI.
>>
>> http://pubs.opengroup.org/onlinepubs/009695399/basedefs/fcntl.h.html
>>
>> On 9/22/16 15:12 , Mariano Martinez Peck wrote:
>>> Hi guys,
>>>
>>> I am wondering if I can wrap some variadic functions (with optional
>>> arguments) with UFFI. Is this possible? If true, how so? For my
>>> particular use case, I am checking if I can call fcntl()
>>> which has a third optional argument.
>>>
>>> Thanks in advance,
>>>
>>> --
>>> Mariano
>>> http://marianopeck.wordpress.com
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: C Variadic Functions via UFFI?

Ben Coman
In reply to this post by Mariano Martinez Peck
On Fri, Sep 23, 2016 at 6:12 AM, Mariano Martinez Peck
<[hidden email]> wrote:
> Hi guys,
>
> I am wondering if I can wrap some variadic functions (with optional
> arguments) with UFFI. Is this possible? If true, how so? For my particular
> use case, I am checking if I can call fcntl()
> which has a third optional argument.
>
> Thanks in advance,


Coincidentally while looking at something else I bumped into these
examples that seem to demonstrate varadic functions...
Alien class >> examplePrintf
Alien class >> exampleVarArgsEnumFontFamiliesEx

cheers -ben