CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Passing NULL as pointer to function gives error

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dev39



Joined: 01 Jan 2010
Posts: 3

View user's profile Send private message

Passing NULL as pointer to function gives error
PostPosted: Fri Jan 01, 2010 5:45 am     Reply with quote

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
}
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Jan 01, 2010 6:04 am     Reply with quote

Code:
_ptr_to_fn_ _NULL = 0;

operation(1,2,_NULL);
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group