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

String size limit lower than 64kB ?

Hello,

I use keil compiler V7.50 with DS80C400 µC in LARGE memory model.

I declare several string constants like this :

const char far image[] = "\x25\x50\x44\x46\x2D\x31\x2E\x34\xD\xA\x25[...]
\x30\x34\x38\xD\xA\x25\x25\x45\x4F\x46\xD\xA";
And there is "#pragma STRING (far)" at the beginning of the file


I noticed 2 problems :

1st : String size limit cannot exceed about 16kB
If one of the string exceed about 16kB, I get this kind of error :
SRC\UTILE.C(255): error C281: illegal hex constant
SRC\UTILE.C(255): error C103: '<string>': unclosed string
SRC\UTILE.C(256): error C141: syntax error near '42'
SRC\UTILE.C(258): error C103: '<string>': unclosed string
Note that I am aware of the 64kB limit for array declaration ( http://www.keil.com/support/docs/3128.htm ). My strings doesn't exceed this limit. And yes my strings are enclosed.

Is there such limitation in string size ? How to declare strings larger than 16kB ?

2sd : Declaring several strings in such way that the total size exceed 64kB stops the compilation
If I place several string declaration in the same file, in such way that none of the string size exceeds 16kB, but the total size of the strings in the file exceed 64kB, I get this error :
SRC\IMAGE.C(360): error C249: '!': SEGMENT TOO LARGE

As a workaround I found that placing the strings in different files solves the problem. However is this normal ? (strings are placed in HCONST memory class which is large enough to contain more than 64kB)

Thanks for your answers.

P.S. note that even though it is not obvious in my example, I need to use strings because most of the declarations use human readable characters !

Parents
  • So, it looks like you're trying to load a static web page into ROM - yes?

    yes, except that web page are not really static, I use sprintf functions to get them alive

    Looks like it might be easier to just have a separate utility that create the HEX file directly, and merge that as a post-build operation?

    Thanks for your suggestion, however I don't think this is the right solution. I use a lots of html files and I have a tool which creates one C file containing all the corresponding vars ; then keil compiler manage to get them at the right memory location automatically. Creating an hex file would mean to handle all the memory organization by hand ...

    Moreover, I am just doing a product upgrade, the actual product is up and running. the size of my files has slightly increased that's why I discovered this 16kB limit.

    I can't change everything just because keil doesn't support what it advertises ! Sorry to be a bit crude but as it seems to be the compiler fault it should be solved at compiler level.

    Regards,
    Xavier

Reply
  • So, it looks like you're trying to load a static web page into ROM - yes?

    yes, except that web page are not really static, I use sprintf functions to get them alive

    Looks like it might be easier to just have a separate utility that create the HEX file directly, and merge that as a post-build operation?

    Thanks for your suggestion, however I don't think this is the right solution. I use a lots of html files and I have a tool which creates one C file containing all the corresponding vars ; then keil compiler manage to get them at the right memory location automatically. Creating an hex file would mean to handle all the memory organization by hand ...

    Moreover, I am just doing a product upgrade, the actual product is up and running. the size of my files has slightly increased that's why I discovered this 16kB limit.

    I can't change everything just because keil doesn't support what it advertises ! Sorry to be a bit crude but as it seems to be the compiler fault it should be solved at compiler level.

    Regards,
    Xavier

Children
  • Are you using an outdated C51 version ? Tried it with C51 V8.01c, here is the result:

    #pragma OMF2 STRING (far)
    
    const char far cTab[] =  {
     "0123456789ABCDEF 0123456789ABCDEF 0123456789ABCDEF 0123456789ABCDEF" // line repeated 978 times ...
    };
    

    compiled with C51 V8.01C, gives:

    MODULE INFORMATION:   STATIC OVERLAYABLE
       CODE SIZE        =   ----    ----
       CONSTANT SIZE    =   ----    ----
       XDATA SIZE       =   ----    ----
       PDATA SIZE       =   ----    ----
       DATA SIZE        =   ----    ----
       IDATA SIZE       =   ----    ----
       BIT SIZE         =   ----    ----
       EDATA SIZE       =   ----    ----
       HDATA SIZE       =   ----    ----
       XDATA CONST SIZE =   ----    ----
       FAR CONST SIZE   =  65393    ----
    END OF MODULE INFORMATION.
    

    Regards,
    Peter