const placed in DATA segment

Hi All,
when I write:
const char mysting[] ={"my string"};

data are placed to DATA segment, not code sement. I know if it would be written like this:

code char mysting[] ={"my string"};

data will be placed in code segment. What I have to do for automatic placing const data to code segment? I did it by #define const code
But may be other ways are exist.

Thanks,
Vladimir

Parents
  • const char mysting[] ={"my string"};
    data are placed to DATA segment, not code sement.

    Correct. const only means read-only from the compiler's point of view. It says nothing of where it is to be stored.

    I know if it would be written like this:

    code char mysting[] ={"my string"};
    Better to write
    const char code myString[] =  "Hello";

    And remember you don't need the { }'s and you should put the code between the type and the variable for future compatiblity.

    - Mark

Reply
  • const char mysting[] ={"my string"};
    data are placed to DATA segment, not code sement.

    Correct. const only means read-only from the compiler's point of view. It says nothing of where it is to be stored.

    I know if it would be written like this:

    code char mysting[] ={"my string"};
    Better to write
    const char code myString[] =  "Hello";

    And remember you don't need the { }'s and you should put the code between the type and the variable for future compatiblity.

    - Mark

Children
More questions in this forum