Is there a way to stop the compiler from issuing warnings about implicit conversion from void*? I thought that the whole point of functions like malloc returning a void * was so that you could assign it to any type of pointer without having to use an explicit cast.
I'm no expert, but in my opinion this should not be a warning. Yes, implicit conversions are bad but if you're converting from void* then I don't see a problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In assignment void * can be converted to the pointer to object or incomplete type, but the qualifier has to remain the same. In other words there is no implicit conversion if you want to assign void * to array, pointer to constant or string literal etc.
tkorrovi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there a way to stop the compiler from issuing warnings about implicit conversion from void*? I thought that the whole point of functions like malloc returning a void * was so that you could assign it to any type of pointer without having to use an explicit cast.
I'm no expert, but in my opinion this should not be a warning. Yes, implicit conversions are bad but if you're converting from void* then I don't see a problem.
In assignment void * can be converted to the pointer to object or incomplete type, but the qualifier has to remain the same. In other words there is no implicit conversion if you want to assign void * to array, pointer to constant or string literal etc.
tkorrovi
Do the cast yourself and the compiler will shut up.
Like: mytype * gizmo = (mytype)malloc(.....
rpeter