unknown size of void *
-
What is the reason of error message: error C2036: 'void *' : unknown size This was a result of compilation of such a code snippet:
void ** c=malloc(20);
int i=1;c[i] = c[i-1]+1;
(Forget uninitialized block of memory
c
) I'd expect that size of any pointer is known. -
What is the reason of error message: error C2036: 'void *' : unknown size This was a result of compilation of such a code snippet:
void ** c=malloc(20);
int i=1;c[i] = c[i-1]+1;
(Forget uninitialized block of memory
c
) I'd expect that size of any pointer is known.The pointer points to something which is not known (otherwise, you would have used int* for instance). Thus, when you are accessing it as an array, the compiler doesn't know how much offset he has to apply to the address to access the following element (because he doesn't know the size of an element). If you want to manipulate bytes, I suggest that you use an array of unsigned char instead.
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
What is the reason of error message: error C2036: 'void *' : unknown size This was a result of compilation of such a code snippet:
void ** c=malloc(20);
int i=1;c[i] = c[i-1]+1;
(Forget uninitialized block of memory
c
) I'd expect that size of any pointer is known.I dont think it is a good practice to allocate a viod pointer. Void pointer is not introduded so as to allocate and use, rather its use is in holding data. Since Void can hold any type of data. You cannot able to allocate the exact length. Thats why complier doesnot allow you to do so. So it better to allocate for some data types. :)
-
What is the reason of error message: error C2036: 'void *' : unknown size This was a result of compilation of such a code snippet:
void ** c=malloc(20);
int i=1;c[i] = c[i-1]+1;
(Forget uninitialized block of memory
c
) I'd expect that size of any pointer is known.c[i-1] is a void * c[i-1] + 1 you're trying to increment to the next "void" object, but void has no size change the line of code
void** c = malloc(20)
to
int** c = malloc(20)
and you'll see that it compiles.
-
What is the reason of error message: error C2036: 'void *' : unknown size This was a result of compilation of such a code snippet:
void ** c=malloc(20);
int i=1;c[i] = c[i-1]+1;
(Forget uninitialized block of memory
c
) I'd expect that size of any pointer is known.liquid_ wrote:
I'd expect that size of any pointer is known.
This is true. Size of a pointer is 32 bits in 32-bit Windows and 64 bits in 64-bit Windows. But the error talks about something else. Consider this example.
int* i = 10;
This uses 4 bytes to store the value 10char* c = 10;
This uses 1 byte to store the value 10 This is what the above error talks about. So if you dovoid* v = 10;
you should get this error since the compiler is not able to get the size needed.«_Superman_» I love work. It gives me something to do between weekends.