Where is possible really get support from KEIL ?
I believe you have a C language mistake, not a compiler bug.
// ---- Beginning of ERR_PTR.C ---- typedef unsigned char UCHAR; typedef void * PTVOID; typedef struct { // Some structure with size <= 4 bytes UCHAR uc0; UCHAR uc1; UCHAR uc2; UCHAR uc3; } STR_A, *PTSTR_A; typedef struct { // Some structure with size > 4 bytes UCHAR uc0; UCHAR uc1; UCHAR uc2; UCHAR uc3; UCHAR uc4[10]; } STR_B, *PTSTR_B; // 'volatile' just to prevent optimizing volatile PTSTR_A pa1,pa2; volatile PTSTR_B pb1,pb2; PTSTR_A f_a( PTVOID p) { return( (PTSTR_A) p ); } PTSTR_B f_b( PTVOID p) { return( (PTSTR_B) p ); } void main(void) { *pa1 = *pa2; //OK_1, (copy via ?C?BMOVEPP8) *pb1 = *pb2; //OK_2, (copy via ?C?BMOVEPP8) *pa1 = *f_a( (PTVOID) pa2 ); // BUG_1: you've stripped the volatile qulifier. *pb1 = *f_b( (PTVOID) pb2 ); // BUG_2: you've stripped the volatile qulifier. }
typedef struct { // Some structure with size <= 4 bytes volatile UCHAR uc0; volatile UCHAR uc1; volatile UCHAR uc2; volatile UCHAR uc3; } STR_A, *PTSTR_A; typedef struct { // Some structure with size > 4 bytes volatile UCHAR uc0; volatile UCHAR uc1; volatile UCHAR uc2; volatile UCHAR uc3; volatile UCHAR uc4[10]; } STR_B, *PTSTR_B; // Pointers point to a struct with all elements volatile. We don't need volatile // on our struct pointers now. PTSTR_A pa1,pa2; PTSTR_B pb1,pb2; // and then replace f_a and f_b with proper casts. Simple is better. pb1 = (PTSTR_B *) pba1; pb2 = (PTSTR_B *) pba2;
>I believe you have a C language mistake, not a compiler bug In real program: - there are no 'volatile' attributes and called functions are 'extern'. - 'Typedefs' widely used in real program by compatibility and easy porting reason's. However, 1) Keyword 'volatile' was added just in example only to prevent compiler optimization and in fact have no meaning for discussed problem. 2) All used in example 'Typedefs' also have no meaning for discussed problem, the same result if using
STR_A * f_a( void * p) {...}
PTSTR_A f_a( PTVOID p) {...}
// This line produce crazy code or no code at all ... *ptr_To_Structure_X = *function_Returning_Ptr_To_Structure_X();
// This line produce true code - just save function result to temporary pointer tmp_ptr_To_Structure_X = function_Returning_Ptr_To_Structure_X(); // This line work good because produce call to library function *ptr_To_Structure_X = *tmp_ptr_To_Structure_X;
Sergey, I looked through our support log and only found 1 e-mail that we just received from you on February 15, 2001. I didn't see that any other e-mails came to support@keil.com or support.us@keil.com from you since the beginning of the year. Maybe you used a different e-mail address? You may also want to check your sent items folder to be sure you actually sent the e-mail to us. Since you are located outside of North/South America, we forwarded your request on to Germany for technical support. Most of the office there has been out last week at the Embedded Systems Show, so turn-around time for questions was probably slow because of that. Nonetheless, I have been able to duplicate the problem you are speaking of and have forwarded it to engineering. We should hear something in a few days on that. Jon
If you supply me with your email, I can resend all my original letters to: <support@keil.com> <support.us@keil.com> <support.intl@keil.com> <Rudolf Baumgartner> <Reinhard Keil> More punctually, one answer I receive from email-robot on 'support@keil.com' that my inquire was recended to support.intl@keil.com. Thats all.