dev39
Joined: 01 Jan 2010 Posts: 3
|
Passing NULL as pointer to function gives error |
Posted: Fri Jan 01, 2010 5:45 am |
|
|
Hi,
I am trying to pass NULL for pointer to function, the compiler complains
"Expecting function Name". Is there any way I can pass NULL for pointer to function. Compiler version is 4.081.
Code: |
#include <18F46K20.h>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <stdio.h>
typedef int (* _ptr_to_fn_)(int a,int b);
int test(int a , int b){
return (a+b);
}
int operation(int a, int b, _ptr_to_fn_ fn){
return (*fn)(a,b);
}
void main(){
operation(1,2,test); //compiles ok
operation(1,2,NULL); //Error 53: Expecting function name
}
|
|
|