I have a volatile char * start_address; which is pointing to register sections (might change due to hardware behavior). I need to read it and I am using:
memcpy (
result_p, // starting address of destination
start_address, // starting address of source
result_len // for the length of the payload
);
I am getting this warning:
passing argument 2 of '
memcpy' discards 'volatile' qualifier from pointer target type
Is a safer way to read the sections or a better way to use memcpy and prevent this warning?
result_len? Are the registers all 8-bits with no gaps in between registers? Personally, usingmemcpywould not be my first choice when dealing with hardware registers. But without more information about the hardware, it's difficult to answer your question.volatile. It is severely underspecified by the standard and it doesn't make things thread safe (although many people seem to believe that), it mostly just serves to inhibit the optimizer from doing clever things with your code. Are you sure you don't actually want an atomic variable?volatileis the correct qualifier.