Re: C- Syntax to allocate Global variables to consecutive memory locations



On Mon, 9 Apr 2007 19:32:52 -0400, "Stan Katz" <stankatz@xxxxxxxx>
wrote:

"Jonathan Kirwan" <jkirwan@xxxxxxxxxxxxxx> wrote

To put my question in exact context, one of the things I miss having
in C and readily find with assembly coding (usually) is the ability to
define link-time constants. By this, I mean the equivalent in x86 asm
of:

_abc EQU 0x123
PUBLIC _abc

This places a symbolic value in the OBJ file that can be linked into
other files and used as constant values. In c, I might use:

extern int abc;
#define MYCONST (&abc)

and then refer to MYCONST throughout the c source. The result allows
me to modify the constant definitions without requiring recompilation
of the c sources. The link process is all that is required.

The way to use this is with the const keyward, in one module you have the
line

const int abc = 0x123;

In the corresponding header file you have

extern const int abc;

then any module that includes the header fine can refer to the integer
constant abc, and to change the value of abc you simply change the value in the module
where it is defined (and assigned), recompile that module and re-link.

Thanks, Stan. But this doesn't do what I said. Did you read me
carefully?

Jon
.



Relevant Pages