This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

external reference to abs xdata

I am trying to come up with a method for defining absolute (MMIO) addresses once in my universal .h file.
DATAACT id defined in one .c file only

UX* is xdata unsigned char

My attempt:

#ifdef DATACT
#define UXRG(name,addr)             UX8 name _at_ addr;
#else
#define UXRG(name,addr)             extern UX8 name;
#endif

used as
UXRG (XRleds, 0xff00);

any suggestions ?

Erik

Parents

  • I've used that method on projects as large as about 1.2 million lines with no problems. (Not for an 8051 of course!)

    After all, you don't (or shouldn't) directly reference global variables very often, particularly in a sizeable project.

    If you forget to change one of the places, the compiler (and lint, and the linker) will immediately remind you, as you'll have mismatched types, unresolved symbols, and so on.

    You'll still have to make the change in two places, albeit two that are a lot closer together, and at the cost of an extra level of macro obscuration in the source.

    But whatever you prefer; seems like you like your original method. (If you didn't actually want suggestions for alternatives, why ask for them?)

Reply

  • I've used that method on projects as large as about 1.2 million lines with no problems. (Not for an 8051 of course!)

    After all, you don't (or shouldn't) directly reference global variables very often, particularly in a sizeable project.

    If you forget to change one of the places, the compiler (and lint, and the linker) will immediately remind you, as you'll have mismatched types, unresolved symbols, and so on.

    You'll still have to make the change in two places, albeit two that are a lot closer together, and at the cost of an extra level of macro obscuration in the source.

    But whatever you prefer; seems like you like your original method. (If you didn't actually want suggestions for alternatives, why ask for them?)

Children