Is void** an acceptable type in ANSI-C?

前端 未结 6 1905
余生分开走
余生分开走 2021-01-05 10:06

I have seen a function whose prototype is:

int myfunc(void** ppt)

This function is called in a C file as a = myfunc(mystruct **var1);<

6条回答
  •  北荒
    北荒 (楼主)
    2021-01-05 10:13

    void** is valid but, based on your error message, you probably have to explicitly cast the argument as follows:

    mystruct **var1;
    x = myfunc ((void**) var1);
    

    That's because the myfunc function is expecting the void** type. While void* can be implicitly cast to any other pointer, that is not so for the double pointer - you need to explicitly cast it.

提交回复
热议问题