0

I got Warning at code "CT_PD->bank = PDbank", Warning happens as long as "CT_PD->...", I have no idea to solve it. Can anyone know what to do?

warning message:: warning 88: cast of LITERAL value to 'generic' pointer from type 'const-int literal' to type 'struct __00000000 generic* fixed'


typedef struct  {
    uint8_t bank;
    .....
    uint8_t xxx;
} CT_PD_Type;
#define PDbank  0x24
#define REGISTER_BASE     0x2000 //register address base
#define CT_PD                 ((CT_PD_Type *) REGISTER_BASE)

void blockWait(uint32_t dura_ms){
    uint32_t expire, duration;
    duration = PE_timer_freq/1000*dura_ms;
    CT_PD->bank = PDbank;
    expire = (CT_PD->timercounter) + duration;
    while(1){
        if (CT_PD->timercounter > expire)
            break;
    }
}

fang jack
  • 83
  • 1
  • 9
  • Well, it is a just warning, and it points you to a implementation-defined conversion, as the standard words it. If the resulting assembly code is correct, you can ignore it. Do you simply want to suppress the warning, or do you want some change in the expression? BTW, please add the version of SDCC. ([Edit] your question in answering, please do not post a comment.) – the busybee Oct 18 '22 at 10:07
  • I want to suppress the warning, how can I do it? – fang jack Oct 18 '22 at 10:22

1 Answers1

1

Chapter 3.3.4 of the fine manual says:

--disable-warning <nnnn> Disable specific warning with number <nnnn>.

So you might want to try to add --disable-warning 88 to your compiler command line.


Chapter 3.16 of the fine manual says:

SDCC supports the following #pragma directives:

[...]

disable_warning <nnnn> - the compiler will not warn you anymore about warning number <nnnn>.

So you can add #pragma disable-warning 88 to your source, as an alternative.

the busybee
  • 10,755
  • 3
  • 13
  • 30