これが私のセットアップです:
public.h:
#ifndef PUBLIC_H_
#define PUBLIC_H_
#include "func.h"
/*extern typedef struct _my_private_struct PRIVATE_;*/
typedef struct _my_private_struct PRIVATE_; /* Thanks to larsmans and Simon Richter */
#endif
struct.h で
#ifndef STRUCT_H_
#define STRUCT_H_
struct _my_private_struct {
int i;
};
#endif
func.h で:
#ifndef FUNC_H_
#define FUNC_H_
#include "struct.h"
/* typedef struct _my_private_struct PRIVATE_; */
extern PRIVATE_ * get_new(int);
#endif
func.c:
#include <stdlib.h>
#include "func.h"
PRIVATE_ * get_new(int i)
{
PRIVATE_ *p = (PRIVATE_ *) malloc(sizeof(PRIVATE_));
if (p == NULL) return NULL;
p->i = i;
return p;
}
main.c で:
#include "public.h"
int main(int argc, char ** argv)
{
PRIVATE_ *p = get_new(2);
return 0;
}
これらのファイルを GCC でコンパイルすると、次のエラーが発生します。
古いコンパイル エラー
宣言指定子の複数のストレージ クラス
編集後のコンパイル エラー
「*」トークンの前に「=」、「,」、「;」、「asm」、または「__attribute__」が必要です
誰かが私を助けてくれたり、なぜ私がこれを手に入れたのか、それを修正する方法を説明できますか?