Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
I cant get va_arg to pull in an argument of type pointer-to-function.
I cant get va_arg to pull in an argument of type pointer-to-function.
✍: Guest
Try using a typedef for the function pointer type.
The type-rewriting games which the va_arg macro typically plays are stymied by overly-complicated types such as pointer-to-function. To illustrate, a simplified implementation of va_arg is
#define va_arg(argp, type) \
(*(type *)(((argp) += sizeof(type)) - sizeof(type)))
where argp's type (va_list) is char *. When you attempt to invoke
va_arg(argp, int (*)())
the expansion is
(*(int (*)() *)(((argp) += sizeof(int (*)())) - sizeof(int (*)())))
which is a syntax error (the first cast (int (*)() *) is meaningless).
If you use a typedef for the function pointer type, however, all will be well. Given
typedef int (*funcptr)();
the expansion of
va_arg(argp, funcptr)
is
(*(funcptr *)(((argp) += sizeof(funcptr)) - sizeof(funcptr)))
which works correctly.
2015-06-05, 1164👍, 0💬
Popular Posts:
Which bit wise operator is suitable for checking whether a particular bit is on or off? The bitwise ...
What are the different storage classes in C? C has three types of storage: automatic, static and all...
How to measure functional software requirement specification (SRS) documents? Well, we need to defin...
Can you explain in brief how can we implement threading ? Private Sub Form1_Load(ByVal sender As Sys...
How can we suppress a finalize method? GC.SuppressFinalize ()