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

Constant variable

I have declared around 15 variables as,


code constant float var1 = 1.0;
code constant float var2 = 3.5;
.
.
.
.

when i see my file.m51 the file is showing these variables are located in xdata.

i am using 8031 with external EPROM memory of 64kb and external RAM of 8KB.

i do not know what is happening?

can anybody tell what might be cause for the problem?

  • Well, when I compile your example, I get the following:

    line level    source
    
       1          code constant float var1 = 1.0;
    *** ERROR C129 IN LINE 1 OF MAIN.C: missing ';' before 'float'
       2          code constant float var2 = 3.5;
    
    C51 COMPILATION COMPLETE.  0 WARNING(S),  1 ERROR(S)
    

    The word "constant" is not a C keyword. Maybe you mean "const".

    Jon

  • Ya i am sorry.

    Actually i had declared my variable like this,

    code const float var1 = 1.2;
    code const float var2 = 13.6;
    

    Like that around 15 variables are declared.

    After compilation , i can see the xdata , code size but y the compiler doesnt show the const size?

    In the .Map file also i see that after declaring the const var, the var where it is stored is showing as xdata not as code.

    do i need any setting?