Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 15, 2010 c function as parameter | ||||
---|---|---|---|---|
| ||||
Hello everyone, I'm trying to create a function which awaits a C function as parameter... like this: void myfunction(void C function(uint, void*)) { .... } But... when I try to compile it, I get the follwing error: "found 'function' when expecting ')'". Does anyone knwo what's wrong with my parameters or is it impossible to create such function? Thx for help :). |
May 15, 2010 Re: c function as parameter | ||||
---|---|---|---|---|
| ||||
Posted in reply to useo6 | useo6 Wrote:
> Hello everyone,
>
> I'm trying to create a function which awaits a C function as parameter... like this:
>
> void myfunction(void C function(uint, void*)) {
> ....
> }
>
> But... when I try to compile it, I get the follwing error:
> "found 'function' when expecting ')'".
> Does anyone knwo what's wrong with my parameters or is it impossible to create such function?
>
> Thx for help :).
Sorry, I forgot the name of the parameter (I didn't past it here^^)... the function looks like this:
void myfunction(void C function(uint, void*) callback) {
....
}
|
May 15, 2010 Re: c function as parameter | ||||
---|---|---|---|---|
| ||||
Posted in reply to useo6 | useo6 <useo6@start.bg> wrote: > Hello everyone, > > I'm trying to create a function which awaits a C function as parameter... like this: > > void myfunction(void C function(uint, void*)) { > .... > } > > But... when I try to compile it, I get the follwing error: > "found 'function' when expecting ')'". > Does anyone knwo what's wrong with my parameters or is it impossible to create such function? > > Thx for help :). You will have to use an alias for this: alias extern( C ) void function( uint, void* ) myCFunction; void myfunction( myCFunction param ) { } -- Simen |
May 15, 2010 Re: c function as parameter | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | Simen kjaeraas Wrote:
> useo6 <useo6@start.bg> wrote:
>
> > Hello everyone,
> >
> > I'm trying to create a function which awaits a C function as parameter... like this:
> >
> > void myfunction(void C function(uint, void*)) {
> > ....
> > }
> >
> > But... when I try to compile it, I get the follwing error:
> > "found 'function' when expecting ')'".
> > Does anyone knwo what's wrong with my parameters or is it impossible to
> > create such function?
> >
> > Thx for help :).
>
> You will have to use an alias for this:
>
> alias extern( C ) void function( uint, void* ) myCFunction;
>
> void myfunction( myCFunction param ) {
> }
>
> --
> Simen
Thanks, works perfectly :)
|
Copyright © 1999-2021 by the D Language Foundation