Menu

implicit conversions from void *

2002-12-05
2012-09-26
  • Nobody/Anonymous

    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.

     
    • Nobody/Anonymous

      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

       
    • Nobody/Anonymous

      Do the cast yourself and the compiler will shut up.
      Like: mytype * gizmo = (mytype)malloc(.....

      rpeter

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.