ヘッダー typedef structについて
Posted: 2010年5月01日(土) 15:20
連日申し訳ありません。ubuです。
添付したファイルをgcc version 4.3.3でコンパイルすると、
以下のようにコンパイルエラーが出力されました。
make dep
make
g++ -c A.cpp
In file included from A.cpp:4:
struct.h:3: error: conflicting declaration ‘typedef struct t_struct t_struct’
struct.h:3: error: ‘t_struct’ has a previous declaration as ‘typedef struct t_struct t_struct’
これはtypedef structが何度も定義されているからこのようになってしまっているのでしょうか?
また、struct.hで多重インクルードガードをつけると、
今度は2度目以降、struct.hを参照した時に、typedef structの実体が見えなくなり、
これもダメです。
どのようにすれば解決できるのでしょうか?
添付したファイルをgcc version 4.3.3でコンパイルすると、
以下のようにコンパイルエラーが出力されました。
make dep
make
g++ -c A.cpp
In file included from A.cpp:4:
struct.h:3: error: conflicting declaration ‘typedef struct t_struct t_struct’
struct.h:3: error: ‘t_struct’ has a previous declaration as ‘typedef struct t_struct t_struct’
これはtypedef structが何度も定義されているからこのようになってしまっているのでしょうか?
また、struct.hで多重インクルードガードをつけると、
今度は2度目以降、struct.hを参照した時に、typedef structの実体が見えなくなり、
これもダメです。
どのようにすれば解決できるのでしょうか?