??? 11/21/07 15:48 Read: times |
#147311 - thanks Responding to: ???'s previous message |
Hello Brett,
I compiled Your posting on ARM-GCC and IAR_ARM_EWKickstart. Now GCC produces many warnings, IAR- warnings an errors. Anyway, i must learn more for pointers. Thank You for help! If not bored - one last question: I suppose this code is compiled well on Your system. What statement is ok to call function pointed by "myfunctionptr" ( commented below "POINTEDfunctionAA")? regards Stefan ARM-GCC warnings: #define __MAIN_C__ const char mychar1[6]="ABCDEF"; const char *mycharptr; int mymode; void xgetstr1(void); void xgetstr2(void); typedef struct {int mode; void (*funcptr1)();//warning: function declaration isn't a prototype const void (*funcptr2)(); //warning: function declaration isn't a prototype //type qualifiers ignored on function return type } myoneset; void xgetstr1(void){ mycharptr=&mychar1[0];} void xgetstr2(void){ mycharptr=&mychar1[1];} myoneset listofsets[2] = {{1,&xgetstr1,&xgetstr2}, {3,&xgetstr2,&xgetstr1}}; //initialization from incompatible pointer type int main (void) { const void (*myfuncptr)();//warning: function declaration isn't a prototype int i ; mycharptr=&mychar1[0]; mycharptr=&mychar1[2]; myfuncptr=&xgetstr1;//warning assignment from incompatible pointer type myfuncptr=listofsets[0].funcptr1; //warning assignment from incompatible pointer type myfuncptr=listofsets[1].funcptr2; myfuncptr=0; mymode=2; for (i=0;i<2;i++) { if (listofsets[0].mode==mymode) myfuncptr=listofsets[1].funcptr2; //POINTEDfunctionAA } return(0); } IAR-ARM errors #define __MAIN_C__ const char mychar1[6]="ABCDEF"; const char *mycharptr; int mymode; void xgetstr1(void); void xgetstr2(void); typedef struct {int mode; void (*funcptr1)(); const void (*funcptr2)(); //Warning[Pe815]: type qualifier on return type is meaningless D:\Documents and Settings\s.d.k\workspace\mynewprj\src\mymain.c 11 } myoneset; void xgetstr1(void){ mycharptr=&mychar1[0];} void xgetstr2(void){ mycharptr=&mychar1[1];} myoneset listofsets[2] = {{1,&xgetstr1,&xgetstr2}, {3,&xgetstr2,&xgetstr1}};//Error[Pe144]: a value of type "void (*)(void)" cannot be used to initialize an entity of type "void const (*)()" D:\Documents and Settings\s.d.k\workspace\mynewprj\src\mymain.c 19 int main (void) { const void (*myfuncptr)();//Warning[Pe815]: type qualifier on return type is meaningless int i ; mycharptr=&mychar1[0]; mycharptr=&mychar1[2]; myfuncptr=&xgetstr1;//Error[Pe513]: a value of type "void (*)(void)" cannot be assigned to an entity of type "void const (*)()" myfuncptr=listofsets[0].funcptr1;//Error[Pe513]: a value of type "void (*)()" cannot be assigned to an entity of type "void const (*)()" D:\Documents and myfuncptr=listofsets[1].funcptr2; myfuncptr=0; mymode=2; for (i=0;i<2;i++) { if (listofsets[0].mode==mymode) myfuncptr=listofsets[1].funcptr2; } return(0); } |
Topic | Author | Date |
Sequence of learning 8051, asm and C | 01/01/70 00:00 | |
2 Issues | 01/01/70 00:00 | |
my wrong path | 01/01/70 00:00 | |
OT, but | 01/01/70 00:00 | |
OT - error message | 01/01/70 00:00 | |
Use the tags | 01/01/70 00:00 | |
single-character const | 01/01/70 00:00 | |
QED? | 01/01/70 00:00 | |
As Erik suggests | 01/01/70 00:00 | |
Just learning - too luxury. | 01/01/70 00:00 | |
how can that be "too luxorious" | 01/01/70 00:00 | |
Foolish builder? | 01/01/70 00:00 | |
pointer to a const | 01/01/70 00:00 | |
True, but... | 01/01/70 00:00 | |
Explaining | 01/01/70 00:00 | |
helpfull ,thanks, but.. | 01/01/70 00:00 | |
Declaration | 01/01/70 00:00 | |
thanks | 01/01/70 00:00 | |
Adjust declaration | 01/01/70 00:00 | |
thanks again | 01/01/70 00:00 | |
const | 01/01/70 00:00 | |
no wrong path | 01/01/70 00:00 | |
learning C | 01/01/70 00:00 | |
Freebies | 01/01/70 00:00 | |
Erik is right | 01/01/70 00:00 | |
not necessary | 01/01/70 00:00 | |
You\'re skipping the most important step ... | 01/01/70 00:00 |