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

Implmenet Below code in MDK-ARM while code work fine in C51

1.

const unsigned char me[] ={6,"my_lcd"};       // works fine in C51 compiler.

.

while in armcc compiler it gives error:

.
error:  #144: a value of type "char *" cannot be used to initialize an entity of type "const uint8_t"

.

2. How to get it done in armcc compiler also. I have writing decimal no in front, to store how many characters a string will have

Parents Reply Children
  • Thanks for your reply.

    Actually I have 140 strings like this with different length. Implementing it by your first method will be too cumbersome & second method require fixed character length.

    Currently I have stored 140 strings by pointer of arrays.
    why it is been compiling in C51 compiler. Yes toolchain is different. But both used C90.
    I think I could copy that segment of code which I made earlier.

  • why it is been compiling in C51 compiler. Yes toolchain is different. But both used C90.

    Well, the C51 compiler is wrong about this. And by the way, you said "both used C90" when in fact you should have said "both aim to comply with C90". You just found a bug in C51's implementation of C90.

  • #include <stdio.h>
    
    const char * const Texts[] =
    {
        "Text-0",
        "Text-1",
        "Text-2",
        "Text-3-extra"
    };
    
    const int Text_Size[] =
    {
        sizeof("Text-0"      ),
        sizeof("Text-1"      ),
        sizeof("Text-2"      ),
        sizeof("Text-3-extra")
    };
    
    int main(void)
    {
        int i;
    
        for ( i = 0; i < 4; i++ )
        {
            printf( "%s, ",        Texts[i] );
            printf( "size = %d\n", Text_Size[i] );
        }
    
        return 0;
    }