Wrapping C that uses compiler extensions

"Jérôme M. Berger" jeberger at free.fr
Sat Mar 5 06:20:41 PST 2011


simendsjo wrote:
> On 05.03.2011 08:58, "Jérôme M. Berger" wrote:
>> simendsjo wrote:
>>> On 04.03.2011 22:42, "Jérôme M. Berger" wrote:
>>>> int main(string[] args) {
>>>>      auto s1 =(); // MH MH
>>>>      auto s2 =(); // OK
>>>>      s2.c =ull; // OK
>>>>      return 0;
>>>> }
>>>
>>> Is part of your message gone?
>>>
>>     Uh, I did not write that.
> 
> Checked the web newsinterface, and I see your post. In thunderbird I got
> another post from Tom with the subject "Struct reference returning
> function and const members" in your post...
> 
>>>> You can safely ignore the “ATTRIBUTE_FORMAT_FPTR(printf, 4, 5)”.
>>>
>>> That I understood :) Thanks!
>>
>>     Then if the issue is with the rest of the definition, it is more or
>> less equivalent to (you will need to translate the argument
>> declaration too):
>>
>> alias size_t function (struct charset_info_st *, char *to, size_t n,
>>                         const char *fmt,
>>                         ...) snprintf;
>>
>>         Jerome
> 
> The definition is inside a struct. I shouldn't use an alias then..?
> 
	No, you are right, I thought there was a typedef in the C code...

> This is the C struct:
> typedef struct my_charset_handler_st
> {
>   // snip
>   size_t (*snprintf)(struct charset_info_st *, char *to, size_t n,
>                      const char *fmt,
>                      ...) ATTRIBUTE_FORMAT_FPTR(printf, 4, 5);
>   // snip
> }
> 
> And this is my D struct:
> struct my_charset_handler_st
> {
>   // snip
>   size_t  function(charset_info_st*, char* to, size_t n,
>                 const char* fmt,
>                 ...) snprintf;
>   // snip
> }
	Yes, that should be about right.

		Jerome
-- 
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110305/970dc031/attachment-0001.pgp>


More information about the Digitalmars-d-learn mailing list