I am in a situation where i a开发者_开发问答m getting an extra warning in my C code.
warning #2513-D: a value of type "volatile char *" cannot be assigned to an entity of type "char *" A = B;
when i checked my code i found that A and B are defined like:
register char *A;
extern volatile char *B;
Can anyone please suggest me how do i type cast to ignore the above warning. Is there any bad impact or side effect if i do type casting. I dont want to change the declaration of A, though it works fine and remove the warning. But changing the declaration of A will have major impact in my code.
Please suggest some way.
Thanks Goldi
The register keyword can be ignored. You could cast like
A = (char *) B;
Casting away the volatile
means that some optimizations (when using the new value of A) could lead to stale values being used, whereas the same computation using B would produce a different (and arguably better) result.
Assuming we're talking about C. C++ is similar, but not quite identical AFAIK, even if it shouldn't matter in this case.
精彩评论