This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How can I ensure that variables declared are in same order in map (output) file as they declared in header file

hello,

How can I ensure that variables declared are in same order in map (output) file as they declared in header file.

 

For example let I have 6 var.

 

UINT32                 t1Var;

UINT16                 t1Var;

UINT16                 t1Var[3];

Char                       t1Var[5];

UINT32                 t1Var;

UINT16                 t1Var; 

kindly, suggest a solutuion without using the structure . i dont want to use structure due to any reason 

  • tushar jindal said:
    suggest a solution without using the structure

    If you restrict things to C code, then there is no solution.  The compiler is free to place variables in memory in any order.

    You could create these variables in a hand-coded assembly file, and thereby have complete control over the order.  It is not that hard.  Write some C code that does nothing but define a few different global variables.  Build with the option -k, so the compiler generated assembly file is kept and not deleted.  Then inspect that file.  It has the same base name as the C file, with the extension changed to .asm.  Note the assembler directives used.  Read up on those directives in the C2000 assembly manual.  Then use those directives in your hand-coded assembly file.

    Thanks and regards,

    -George