c - Typecasting return value of function to pointer type -
i have following code:
#define pll0stat (*((volatile unsigned short*) 0xe01fc088)) // function prototypes void diaplayinrow1withposition(unsigned char* data, unsigned char position); unsigned char convertlowernibbletoasciivalue(unsigned char data); void func1 (void) { unsigned char temp = (unsigned char) pll0stat; // interested in last byte temp = convertlowernibbletoasciivalue(temp); diaplayinrow1withposition(&temp,15); }
instead of above code, thought replace last line 1 step , used below statement
diaplayinrow1withposition(((unsigned char*)convertlowernibbletoasciivalue(temp3)),15);
but code compiles correctly, nothing displayed in lcd. not able makeout reason. typecasting done correctly pointer thought. there other issue?
the original code fine. why trying turn unreadable one-liner, have no idea. not gain performance, achieve nothing, obfuscate code. can see need ask question: have made code unreadable yourself. leave code was.
the actual bug comes strange cast (unsigned char*)
have added.