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

STDOUT redirection

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



Joined: 17 Nov 2005
Posts: 30
Location: Chester UK

View user's profile Send private message

STDOUT redirection
PostPosted: Tue Oct 20, 2009 9:37 am     Reply with quote

Is there are way to redefine the default STDOUT to use my own choice of comms? As far as I can tell the compiler associates STDOUT with the last #use statement. Whilst I realise the ease of using #use RS232 functionality I am wondering if I can avoid it as I am trying to use generic code (for compatability with HiTech compilers) wherever possible, i.e. not use #use RS232.
I had hoped it was as as simple as just defining my own putc() and getc() routines which the compiler would then use for printf etc? However, when I try doing this (& deliberately miss out the #use RS232) the compiler gives errors, suggesting I might need a #use RS232 statement.
I realise there is another method & that is to use printf(fname, cstring ...) where I define my own fname, but again, this is rather non-standard.
What I had hoped for was just a means to redirect/define STDOUT to suit my own needs so that printf would default to that?
Any ideas ?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Oct 20, 2009 1:37 pm     Reply with quote

As far as I see, there's no other way than using the CCS proprietary printf() syntax. STDOUT respectively putchar() is a special compiler built-in stream/function, that can't be redefined.

To achieve compatibility with other compilers, preprocessor macros are required.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 20, 2009 2:07 pm     Reply with quote

You could put #pragma in front of the #use rs232() statement. Then
only CCS would use it. Other compilers would presumably ignore it.
Code:

#pragma use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
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