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 CCS Technical Support

pre-processor __LINE__ not working ?

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



Joined: 05 Aug 2006
Posts: 149
Location: Redditch, UK

View user's profile Send private message Visit poster's website

pre-processor __LINE__ not working ?
PostPosted: Sun Sep 09, 2007 10:37 am     Reply with quote

I have been trying to use __LINE__ to report the current line to help with my debugging.

However PCM 3.249 gives the error :
Line 1375(16,17): Expecting LVALUE such as a variable name or * expression ::

for the following line of code :
printf(__LINE__) ;

if I replace with
printf(__FILE__) ;

its ok ?

Indeed the example given in help file don't work either, CCS says it too long ie :
printf("Too many entries, source file: " __FILE__ " at line " __LINE__ "\r\n");



Whats going on ?

Neil
nurquhar



Joined: 05 Aug 2006
Posts: 149
Location: Redditch, UK

View user's profile Send private message Visit poster's website

PostPosted: Sun Sep 09, 2007 12:11 pm     Reply with quote

Would you believe it, the CCS PCM Documatation is wrong !

__LINE__ is not type char* but long.

Thus to print your line number you actually need to use something like this :

printf("Line : %ld\r\n", __LINE__) ;

And not as implied in the manual :

printf("Line : " __LINE__ "\r\n") ;
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