I'm need to declare incomplete type (may it be siginfo_t) in header, and in source import some system header (sys/signal.h), that defines that type.
So, here is the problem:
// a.h
struct siginfo_t;
void foo(siginfo_t*);
// a.cpp
#include "a.h"
#include <signal.h>
void foo(siginfo_t* x) { /* implementation */ };
But in signal.h it is defined like:
typedef struct siginfo_t { /* */ } siginfo_t;
Compiler error: error: typedef redefinition with different types ('struct siginfo_t' vs 'siginfo_t').
How to achieve no errors there? Thanks!
In the header
<sys/siginfo.h>the typedef namesiginfo_tis an alias for an unnamed structureBut you introduced the same alias name for named structure
So the compiler issues the error
because you may not introduce the same alias name for a named structure and an unnamed structure. These structures are different types.