我需要siginfo_t在标头中声明不完整的类型(可能是),并在源导入中sys/signal.h定义该类型的一些系统标头()。
所以,问题来了:
// a.h
struct siginfo_t;
void foo(siginfo_t*);
Run Code Online (Sandbox Code Playgroud)
// a.cpp
#include "a.h"
#include <signal.h>
void foo(siginfo_t* x) { /* implementation */ };
Run Code Online (Sandbox Code Playgroud)
但在 signal.h 中它的定义如下:
typedef struct siginfo_t { /* */ } siginfo_t;
Run Code Online (Sandbox Code Playgroud)
编译器错误:error: typedef redefinition with different types ('struct siginfo_t' vs 'siginfo_t').
如何实现没有错误呢?谢谢!