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

#define

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







#define
PostPosted: Thu Jun 18, 2009 10:49 am     Reply with quote

Hi Guys

I am using #if defined TypeA or #if defined TypeB throughout my code depending on which of two product types will be connected.
Code:

#if defined(__TYPE_A__)
///code here
#endif
   
#if defined(__TYPE_B__) 
///code here
#endif

This works very well but requires setting TYPE_A or TYPB_B when compiling. I am now looking to be able to switch the type via an rs232 command and wanted to know if I can re-define the system to say type_B from within the code.

Is it possible to just run the command
Code:
#define     __STYPE_B__


Thanks

Chris.......
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 18, 2009 11:48 am     Reply with quote

The #if statements work at compile-time.

Apparently you want something that works at run-time. One method
would be have an eeprom address set to a certain value. Then you
could read the eeprom address at start-up, and load it into a RAM
variable. Then test that RAM variable at suitable points in your program
with if() statements to control program flow.
CAP1108
Guest







Will give this a go
PostPosted: Fri Jun 19, 2009 2:05 am     Reply with quote

Thanks for the advice.

Will give this a go

Chris ..........
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