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

What a mess! (about structures)

The following is a part of one of my source file:

struct s{char *p};
struct s code a = {"string1"};
struct s code b = {"string2"};
I wonder how the structures, 'a' and 'b', are arranged in the memory on Cx51 chips. Are they placed consecutively in the order as they are declared, while the two strings are placed somewhere else, or 'a' first then "string1", then 'b' and the last "stirng2"?

Parents
  • part of the C spec is "C can place anything anywhere it feels like"

    If you want such control do it in assembler.

    I have cases where (for other reasons) I will have things like

    phread.a51 will have
    cigar ds 256
    pipe ds 256

    momma.h will have
    extern xdata U8 cigar[];
    extern xdata U8 pipe[];

    that way cigar and pipe are consequtive. Any C module can include momma.h and use the variables.

    Erik

Reply
  • part of the C spec is "C can place anything anywhere it feels like"

    If you want such control do it in assembler.

    I have cases where (for other reasons) I will have things like

    phread.a51 will have
    cigar ds 256
    pipe ds 256

    momma.h will have
    extern xdata U8 cigar[];
    extern xdata U8 pipe[];

    that way cigar and pipe are consequtive. Any C module can include momma.h and use the variables.

    Erik

Children
No data