Hi all, I'm coding graphic LCD routines and I want to include several text fonts. So, I've defined a structure as :
typedef struct DEF_FONT { U8 u8width; /* Character width*/ U8 u8height; /* Character height*/ U8 *au8fontTable; /* Font table start address in memory */ } DEF_FONT;
struct DEF_FONT code Font_System5x8 = {5, 8, au8font5x8}; struct DEF_FONT code Font_System8x8 = {8, 8, au8font8x8};
void LcdPutchar (U8 u8Char, DEF_FONT stFont)
LcdDataWrite (stFont->au8fontTable[(u8Char - 32) * 5 + u8CharColumn]);
***ÿERROR 199 IN LINE 345 OF C:\TRX8051\GLCD.C: left side of '->' requires struct/union pointer
struct DEF_FONT *ptr
I'm using the '->' operator because of a bug of the compiler C51 V5.50 Please report to this link to have the description of the problem from Keil : http://www.keil.com/support/docs/855.htm Note that the two syntax seems to have the same behavior. Dan, I will try your tip tomorrow. I'll keep you informed. Regards Stephane
You can pass structures: void myfunc (DEF_FONT font); or you can pass pointers to structures. void myfund (DEF_FONT* font); They're not the same thing, any more than passing integers versus pointers to integers. People usually pass pointers to structures to save stack space and time. If you pass the structure, then you need to use the '.' operator to dereference fields: font.au8fontTable; If you pass a pointer to the structure, you need to use the '->' operator: font->au8fontTable; The Keil bug references says that the compiler will incorrectly allow you to use '.' to dereference a pointer. However, you shouldn't (and shouldn't be able to) use the "arrow" operator -> on an actual structure.
I've well understood the difference between the '.' and '->' operators now. The suggestion from Dan Henry is working well. My code is working correctly. I had forgotten to define the function using the pointer..... Thanks everybody Regards Stephane