Search code examples
c++11suppress-warningsgcc-warning

Suppress warning:deleting 'void*' is undefined


I know what is this warning and need to suppress this warning. Is there any way using pragma or compiler options are available to suppress this warning?


Solution

  • Better to change the code to avoid this warning rather than suppressing it! If not handled correctly, it may cause runtime surprises which will be much harder to find.

    [Note: To answer your question, which should be taken with a grain of salt, you may use free() instead of delete, as it converts any pointer to void* before deallocating it. Make sure that the destructors are called correctly before it.]