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

Inconsistent warnings about different data types ?

C51 COMPILER V9.53.0.0
LX51 LINKER/LOCATER V4.66.30.0

I have the following (relevant) lines of code:

extern xdata uint8_t rtu_rx_buf[];
extern xdata uint8_t rtu_tx_buf[];
.
.
.
struct{
    uint8_t func;
    uint16_t start;
    uint16_t qty;
    uint8_t  n;
}xdata *p = &rtu_rx_buf[1];
.
.
.
p = rtu_tx_buf;
.
.
.

The first assignment to 'p' doesn't raise any complaints from the compiler or linker. The second, however, gives me the following warnings:

*** WARNING C182 IN LINE 98 OF C:\blahblahblah.c: pointer to different objects
*** WARNING L25: DATA TYPES DIFFERENT

I'm pretty sure I don't see the difference; am I missing something here?

Parents
  • The plot thickens... If I do this instead, I get complaints about both assignments:

    struct{
        uint8_t func;
        uint16_t start;
        uint16_t qty;
        uint8_t  n;
    }xdata *p;
    .
    .
    p = &rtu_rx_buf[1];
    .
    .
    .
    p = rtu_tx_buf;
    .
    .
    .
    
    

    Maybe something else I'm doing is offending it in a much more subtle way. To put things into context a little better, this code is within a case of a switch statement thusly:

    case MB_FUNC_WRITE_MULTIPLE_REGISTERS:
        {
        struct{
            uint8_t func;
            uint16_t start;
            uint16_t qty;
            uint8_t  n;
        }xdata *p = &rtu_rx_buf[1];
        uint16_t st = p->start;
        uint16_t q = p->qty;
        uint8_t n = p->n;
        uint8_t i;
        uint8_t data *dest;
        uint8_t xdata *src;
    
        if(blahblahblah){
            .
            .
            .
            p = rtu_tx_buf;
            .
            .
            .
        }
    
        }
        break;
    
    

Reply
  • The plot thickens... If I do this instead, I get complaints about both assignments:

    struct{
        uint8_t func;
        uint16_t start;
        uint16_t qty;
        uint8_t  n;
    }xdata *p;
    .
    .
    p = &rtu_rx_buf[1];
    .
    .
    .
    p = rtu_tx_buf;
    .
    .
    .
    
    

    Maybe something else I'm doing is offending it in a much more subtle way. To put things into context a little better, this code is within a case of a switch statement thusly:

    case MB_FUNC_WRITE_MULTIPLE_REGISTERS:
        {
        struct{
            uint8_t func;
            uint16_t start;
            uint16_t qty;
            uint8_t  n;
        }xdata *p = &rtu_rx_buf[1];
        uint16_t st = p->start;
        uint16_t q = p->qty;
        uint8_t n = p->n;
        uint8_t i;
        uint8_t data *dest;
        uint8_t xdata *src;
    
        if(blahblahblah){
            .
            .
            .
            p = rtu_tx_buf;
            .
            .
            .
        }
    
        }
        break;
    
    

Children
No data