|
|
View previous topic :: View next topic |
Author |
Message |
simon630
Joined: 07 Sep 2003 Posts: 17
|
can #undef, #define used in subroutine for memory addressing |
Posted: Fri Jul 04, 2003 4:36 am |
|
|
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
|
Re: can #undef, #define used in subroutine for memory addres |
Posted: Fri Jul 04, 2003 6:22 am |
|
|
<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 |
|
|
|
|
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
|