We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi i'm using Keil U vision IDE 3. i'm trying to implement my logic. but it i'm receiving error as: error: #513: a value of type "hc_ed *" cannot be assigned to an entity of type "volatile ulong *"
when i implemented this code in turbo c i haven't recieved any error.
does any one know how to deal with this problem.
code is:
#include <stdio.h> #include <stdlib.h>
typedef unsigned long int ulong; typedef unsigned char uchar; typedef struct _hc_controller_endpoint { volatile ulong control; volatile ulong cbp; volatile ulong *next_td; volatile ulong be; }hc_ed,*phc_ed;
typedef struct _hcd_controller_endpoint { uchar error; uchar packet; volatile ulong status; hc_ed hced; }hcd_ed,*phcd_ed;
int main(void) { int i; phcd_ed ed,trace; for (i=0;i<8;i++) { ed = malloc(sizeof(hcd_ed)); if(ed != NULL) { ed->hced.next_td =&(ed->hced); ed->status =(ulong) &(ed->hced); } // i want to have address in same location. //does there any other way to implement same logic }
}
Exactly why do you think that you have to "deal with this problem"?
If you do need to use a pointer to a generic type, the language standard has the void pointer type.
And never ever assume that it is ok to convert between pointer types - all pointers are not equal. They can have different size. They can have different alignment requirements. They can be partially predefined - fixed to only be able to reach objects in a specific memory range.
Another thing: Please format the code according to the instructions, so that we may read it. And check the preview before posting.
nikhil, Am I seeing a "malloc" over there...? I hope "malloc" is redefined in your project so that you don't really use dynamically allocated memory (but rather memory allocated during compilation in the form of a pool), or just make "hcd_ed" static!