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

can #undef, #define used in subroutine for memory addressing

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



Joined: 07 Sep 2003
Posts: 17

View user's profile Send private message

can #undef, #define used in subroutine for memory addressing
PostPosted: Fri Jul 04, 2003 4:36 am     Reply with quote

Hi, friends,
I am wondering whether these two pre-processor directives could be used in subroutine.
here is a sample programme.

#define SERIAL_NO 5
.
.
.
void routine1(){
if (a>5)
#undef SERIAL_NO
#define SERIAL_NO 10
}

void write_ram(){
//SERIAL_NO is used as the address of memory access
}

main(){

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515735
neil



Joined: 08 Sep 2003
Posts: 128

View user's profile Send private message

Re: can #undef, #define used in subroutine for memory addres
PostPosted: Fri Jul 04, 2003 6:22 am     Reply with quote

<font face="Courier New" size=-1>Hello, I'm not absolutely sure, but I think #define and #undef are just compiler directives which are evaluated by the compiler, not the PIC. If you try to use compiler directives at run time, I would expect the compiler to give an error.

If you want to store a nonvolatile serial number on a chip, but want to be able to change it, why not use a device with internal E�PROM such as 16Fxxx and put the serial no. in E�

Regards,
Neil.

:=Hi, friends,
:= I am wondering whether these two pre-processor directives could be used in subroutine.
:= here is a sample programme.
:=
:=#define SERIAL_NO 5
:=.
:=.
:=.
:=void routine1(){
:=if (a>5)
:=#undef SERIAL_NO
:=#define SERIAL_NO 10
:=}
:=
:=void write_ram(){
:= //SERIAL_NO is used as the address of memory access
:=}
:=
:=main(){
:=
:=}</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515738
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