| ||||||||
Technical Support Support Resources Product Information | C51: LOCATING VARIABLES TO FAR CONST SPACEInformation in this article applies to:
QUESTIONI need to write portable code for my programs and I am using a header file that defines the memory types for the program in a generic way. For example to put a constant into ROM I have used the syntax:
_code_ unsigned char MyConst = {0xAC};
With #define _code_ code the resulting syntax is:
code unsigned char MyConst = {0xAC};
Everything works fine this way, but now I want to put the constants into the far const space. However the definition #define _code_ const far results in syntax errors. What can I do? Note that I do not want to use the following syntax, since I need to have portable code that works on several platforms:
unsigned char const far MyConst = {0xAC};
ANSWERThe correct syntax is #define _code_ far const which results in:
far const unsigned char MyConst = {0xAC};
This compiles fine with the CX51 Compiler or with the C51 Compiler when you use the OMF2 Directive. MORE INFORMATION
SEE ALSO
Last Reviewed: Friday, July 15, 2005 | |||||||
| ||||||||