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

Pointers

Need a clarification.

I want to define two poiners. One pointing to an area in XRAM and the other within CODE memory.

I further want both of these pointers to be stored in XRAM.

unsigned char xdata *xram_pointer;
unsigned char code *code_pointer;

This defines the pointers. But, how do I get them to be stored in XRAM?

As I understand it, this is how it is done:

unsigned char xdata * xdata xram_pointer;
unsigned char code * xdata code_pointer;

Here the "xdata" next to the pointer name specifies that the pointer be stored in XRAM memory.

Is this correct?

Thanks.

Parents
  • A couple of ways to help remember how the qualifers work:

    1) Think of them as left-associative. The qualifiers modify the thing to their left. If there is nothing to their left, then they'll modify the thing to their right.

    2) For pointer declarations, imagine a vertical line drawn through the *. Everything to the left of that line modifies the thing pointed at. Everything to the right of the line modifies the pointer itself.

    const int x; // constant integer
    int const x; // also a constant integer
    int * const x; // const pointer to variable int
    int const * x; // variable pointer to const int
    int const * const x; // const pointer and const int
    const int * const x; // also const pointer and const int

    const int const * x; // both consts apply to the int, not the *

Reply
  • A couple of ways to help remember how the qualifers work:

    1) Think of them as left-associative. The qualifiers modify the thing to their left. If there is nothing to their left, then they'll modify the thing to their right.

    2) For pointer declarations, imagine a vertical line drawn through the *. Everything to the left of that line modifies the thing pointed at. Everything to the right of the line modifies the pointer itself.

    const int x; // constant integer
    int const x; // also a constant integer
    int * const x; // const pointer to variable int
    int const * x; // variable pointer to const int
    int const * const x; // const pointer and const int
    const int * const x; // also const pointer and const int

    const int const * x; // both consts apply to the int, not the *

Children
No data