CDECL Utility
"Jérôme M. Berger"
jeberger at free.fr
Sat Dec 29 23:05:51 PST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Jarrett Billingsley wrote:
> ""J�r�me M. Berger"" <jeberger at free.fr> wrote in message
> news:fl6jpl$1git$1 at digitalmars.com...
>
>>> void function(int sig, void function(int))(int) signal;
>> ^^^^^
>>> Pointer to a function that takes (an int and a (pointer to a function
>>> that
>>> takes an int and returns void)) and returns void.
>>>
>> What's that "(int)" doing here? And would that even compile?
>
> I was trying to convert the C declaration into D from the cdecl page.. I
> have no idea what the (int) is doing in _that_ decl, but it at least is not
> valid D :o
>
Apparently cdecl doesn't like it either :D :
cdecl> explain void (*signal(int sig, void (*func)(int)))(int);
syntax error
However if you remove the parameter names in the declaration, you get:
cdecl> explain void (*signal(int, void (*)(int)))(int);
declare signal as function (int, pointer to function (int) returning
void) returning pointer to function (int) returning void
So I think that the proper D declaration would be:
void function (int sig, void function (int)) function (int) signal;
And like you said, the D way does not need something like cdecl to
be interpreted (in fact, I find the D declaration clearer than the
cdecl output).
Jerome
- --
+------------------------- Jerome M. BERGER ---------------------+
| mailto:jeberger at free.fr | ICQ: 238062172 |
| http://jeberger.free.fr/ | Jabber: jeberger at jabber.fr |
+---------------------------------+------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQFHd0NPd0kWM4JG3k8RAtP+AKCTgnz5nvDDFfzcua3Y5epXQLGwugCglRbL
/W2JkTFplrLjgCsAV2p1C1Y=
=QjCf
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-learn
mailing list