|
-
June 21st, 2002, 03:44 AM
#1
[C] void(*pfunc)(...);
I have made a testprogram in Visual Studio, which uses a functionpointer like this:
Str1, Str2 and Str3 contain the functionaddresses retreived out of the mapfile.
#include "stdargs.h"
void (*pfunc)(...);
memcpy(&pfunc,Str1,4);
pfunc();
memcpy(&pfunc,Str2,4);
pfunc(20);
memcpy(&pfunc,Str3,4);
pfunc(20, "test");
This works great.
But I really want to use this in an embedded ARM system. So I wrote the same code in an ANSI C file for ARM.
For compiling I use the ADS compiler. But this compiler errors on the (...) in the pointer declaration.
When I leave the ... away like this:
void (*pfunc)();
it does not come up with any errors. But I still call functions with 1 or 2 parameters.
Can anyone tell me if this is possible in ANSI C?
And if it is, is it a compiler bug or am I doing something wrong?
-
June 21st, 2002, 05:45 AM
#2
Re: [C] void(*pfunc)(...);
Standard C requires at least one fixed argument. So as you can start parsing the rest of arguments.
Code:
int foo( int arg1, ... )
{
va_list list;
va_start(list, arg1 );
/*...*/
}
ZDF
What is good is twice as good if it's simple.
"Make it simple" is a complex task.
-
June 21st, 2002, 06:26 AM
#3
Also ...
... in C, if you have NO function arguments in the declaration, that means the function can take any number of arguments; in C++, it means that the function takes NO arguments, I believe.
-
June 21st, 2002, 06:35 AM
#4
Re: Also ...
Originally posted by PaulWendt
... in C, if you have NO function arguments in the declaration, that means the function can take any number of arguments; in C++, it means that the function takes NO arguments, I believe.
Does your compiler successfully compile the code below?
ZDF
What is good is twice as good if it's simple.
"Make it simple" is a complex task.
-
June 21st, 2002, 06:43 AM
#5
Re: Re: Also ...
Originally posted by zdf
Does your compiler successfully compile the code below?
Yes it does. But my problem is already answered.
... in C, if you have NO function arguments in the declaration, that means the function can take any number of arguments; in C++, it means that the function takes NO arguments, I believe.
This I did not know. I have not been able to find it either. THanks for the quick answers.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|