Oracle Solaris Studio 12.2: C ユーザーガイド

5.3.2 構造体ポインタへの void ポインタのキャスト

次の例では、void 型のポインタ vp が構造体のポインタとしてキャストされます。lint -Xalias_level=weak (またはそれ以上) を指定すると、警告メッセージが生成されます。


struct foo {
    int a;
    int b;
  };

struct foo *f;
void *vp;

void main()
{
    f = (struct foo *)vp; /* struct pointer cast of void pointer warning */
}