Can anyone give me any ideas on fixing this?warning: passing arg 1 of 'memcpy' discards qualifiers from pointer target type
DJGPP Compiler Warning...
DJGPP Compiler Warning...
Re:DJGPP Compiler Warning...
You've probably done something like this:
memcpy() is prototyped as:
...so by passing const char* as the first parameter, you're discarding the const qualifier.
Code: Select all
const char *str = "Hello ";
mempcy(str, "World", 6);
Code: Select all
void *memcpy(void *dest, const void *src, size_t bytes);
Re:DJGPP Compiler Warning...
My memcpy is as follows...
The code I am calling it from is
Code: Select all
void *memcpy(void *dst_ptr, const void *src_ptr, unsigned count)
{
void *ret_val = dst_ptr;
const char *src = (const char *)src_ptr;
char *dst = (char *)dst_ptr;
for(; count != 0; count--)
*dst++ = *src++;
return ret_val;
}
Code: Select all
static volatile virtual_stream virtual_sessions[10];
FILE *retval = kmalloc(sizeof(FILE));
memcpy(&virtual_sessions[totalvirt].substream, retval, sizeof(FILE));
Code: Select all
typedef struct
{
char *truepath;
int objid;
FILE substream;
} virtual_stream;
typedef struct
{
int type, id;
int location;
int mode;
} FILE;
Re:DJGPP Compiler Warning...
OK, discarding 'volatile' isn't as bad as discarding 'const'. Cast the pointer, removing volatile, and you should be fine. It's generally not a good idea to shut the compiler up by inserting casts, but as long as you understand why, it's OK.