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

Compiling differences between C51 v7.03 and v8.06

Hello!

I have uVision that compiles fine with the C51 v7.03 compiler and the related package, but not complete with the 8.06. I used two different Keil installations. All files are in the same folder.

In the 8.06 I get linker errors like "object does not fit in to pdata page" and "0080H". This looks like the compiler was thinking the PDATA was only 128 bytes, but it is set to 256 bytes in the startup.a51. Any clue what's different in the newer Keil package?

Also there is a warning in 8.06 (which does not show in 7.03) "converting non-pointer to pointer" on this

ptr_xdata = sPtr_obj->Adresse;


while the vars are set like this:

uchar uc_set_obj( uchar pdata *ptr_Set)
{
   uchar i;
   uchar xdata *ptr_xdata;
   struct stOBJADR code *sPtr_obj;

   sPtr_obj=&Obj[*ptr_Set];
   .
   .
   .
   ptr_xdata = sPtr_obj->Adresse;
}


The struct stOBJADR has a member "uint Adresse;"

I can see no wrong use of the pointers. I just want to be sure that the warning does not affect the code to not work correctly.

Parents
  • The address of the pointer (or variable) is the same as the pointer's (or variable's) address, i.e. the location where the pointer (or variable) is stored.

    The value of the pointer is an address - the address that the pointer points to.

    "The address of a pointer is the pointer itself." should be rewritten as:
    "The address of a pointer is the location of the pointer itself".

    The address the pointer points to? That's the value of the pointer. Just as the value of variable my_int below is 5.

    int my_int = 5;
    

    Variables stores values. It doesn't matter what data type the variable has (pointer, pointer, struct, ...), it still stores one or more values.

    As soon as you write more complex programs, you regularly do have to care about the address of the pointer, i.e. where the pointer is stored. Or, more specifically, your application will need the address of your pointer, so that it will be able to indirectly (through a pointer) modify the address stored in the pointer (the pointer's value).

    Look at strtol(const char* str,char **endptr,int base) which takes a pointer to a pointer as second parameter.

    char input_string[] = "12345broken chars";
    char *end;
    long val;
    val = strtol(input_string,&end,10);
    if (*end != '\0')
        printf("Invalid number string\n");
    else
        printf("The value was %ld\n",val);
    


    Now the pointer end (not what it points to) will be modified to point at the first non-valid character in the input string.

    This is a simple case where you use the address of a pointer to change the pointer instead of changing what it points to. There are many more - many of them way more complex - that are commonly used in standard C/C++ programs. Some RTOS may have half their API centering around pointers to pointers... Array manipulation functions are a different area where multiple levels of indirection is often needed.

Reply
  • The address of the pointer (or variable) is the same as the pointer's (or variable's) address, i.e. the location where the pointer (or variable) is stored.

    The value of the pointer is an address - the address that the pointer points to.

    "The address of a pointer is the pointer itself." should be rewritten as:
    "The address of a pointer is the location of the pointer itself".

    The address the pointer points to? That's the value of the pointer. Just as the value of variable my_int below is 5.

    int my_int = 5;
    

    Variables stores values. It doesn't matter what data type the variable has (pointer, pointer, struct, ...), it still stores one or more values.

    As soon as you write more complex programs, you regularly do have to care about the address of the pointer, i.e. where the pointer is stored. Or, more specifically, your application will need the address of your pointer, so that it will be able to indirectly (through a pointer) modify the address stored in the pointer (the pointer's value).

    Look at strtol(const char* str,char **endptr,int base) which takes a pointer to a pointer as second parameter.

    char input_string[] = "12345broken chars";
    char *end;
    long val;
    val = strtol(input_string,&end,10);
    if (*end != '\0')
        printf("Invalid number string\n");
    else
        printf("The value was %ld\n",val);
    


    Now the pointer end (not what it points to) will be modified to point at the first non-valid character in the input string.

    This is a simple case where you use the address of a pointer to change the pointer instead of changing what it points to. There are many more - many of them way more complex - that are commonly used in standard C/C++ programs. Some RTOS may have half their API centering around pointers to pointers... Array manipulation functions are a different area where multiple levels of indirection is often needed.

Children
No data