C++ C++;错误,可能来自.h文件,不确定

C++ C++;错误,可能来自.h文件,不确定,c++,header-files,C++,Header Files,好的,我正在尝试编译一个程序: g++-std=c++0x a1test.cpp GS1Prefix.cpp EAN.cpp 但是我犯了以前从未见过的错误 In file included from a1test.cpp:17:0: EAN.h:3:25: error: âPrefixâ does not name a type EAN.h:3:33: error: ISO C++ forbids declaration of âpâ with no type [-fpermissive] a1

好的,我正在尝试编译一个程序:

g++-std=c++0x a1test.cpp GS1Prefix.cpp EAN.cpp

但是我犯了以前从未见过的错误

In file included from a1test.cpp:17:0:
EAN.h:3:25: error: âPrefixâ does not name a type
EAN.h:3:33: error: ISO C++ forbids declaration of âpâ with no type [-fpermissive]
a1test.cpp: In function âbool RegisteredTests(const Prefix*, int&, int*, int*)â:
a1test.cpp:222:68: error: no matching function for call to âisRegistered(const Prefix*&, const char [14], char [6], char [8], char [7])â
a1test.cpp:222:68: note: candidates are:
EAN.h:3:6: note: bool isRegistered(const int*, const char*, char*, char*, char*)
EAN.h:3:6: note:   no known conversion for argument 1 from âconst Prefix*â to âconst int*â
GS1Prefix.h:10:6: note: bool isRegistered(const Prefix*, int)
GS1Prefix.h:10:6: note:   candidate expects 2 arguments, 5 provided
这只是错误的一半,下面我有所有的.h文件和到a1test.cpp的链接(代码很长)

EAN.h

GS1Prefix.h

const int MAX = 700;
struct Prefix {
    int  no;             // number of entries
    int  area[MAX];      // area elements
    char pubLow[MAX][8]; // low end of publisher range
    char pubHgh[MAX][8]; // high end of publisher range
    int  pubLen[MAX];    // no of chars in publisher string
};
bool load(const char* filename, Prefix* p);
bool isRegistered(const Prefix* p, int area);
int minNoDigits(const Prefix* p, int area);
bool isRegistered(const Prefix* p, int area, const char* publisher);
链接到a1test.cpp->

更新:根据remyabel的建议,我在“include”之后添加了“GS1Prefix.h”


只需切换头的顺序,代码就可以正常编译。由于您没有提供
GS1Prefix.cpp
EAN.cpp
我无法对其余错误(如果还有任何错误)发表评论

#包括
//GS1Prefix.h
常数int MAX=700;
结构前缀{
int no;//条目数
int区域[MAX];//区域元素
char pubLow[MAX][8];//发布服务器范围的低端
char pubHgh[MAX][8];//发行商范围的高端
int pubLen[MAX];//发布者字符串中的字符数
};
//EAN.h
bool是有效的(const char*str);
bool已注册(常量前缀*p,常量字符*str,字符区域[],字符发布者[],字符标题[]);
//a1test.cpp
bool load(常量字符*文件名,前缀*p);
bool已注册(常量前缀*p,int区域);
int minNoDigits(常量前缀*p,int区域);
bool已注册(常量前缀*p,int区域,常量字符*publisher);
// .. 文件的其余部分

只需切换头的顺序,代码就可以正常编译。由于您没有提供
GS1Prefix.cpp
EAN.cpp
我无法对其余错误(如果还有任何错误)发表评论

#包括
//GS1Prefix.h
常数int MAX=700;
结构前缀{
int no;//条目数
int区域[MAX];//区域元素
char pubLow[MAX][8];//发布服务器范围的低端
char pubHgh[MAX][8];//发行商范围的高端
int pubLen[MAX];//发布者字符串中的字符数
};
//EAN.h
bool是有效的(const char*str);
bool已注册(常量前缀*p,常量字符*str,字符区域[],字符发布者[],字符标题[]);
//a1test.cpp
bool load(常量字符*文件名,前缀*p);
bool已注册(常量前缀*p,int区域);
int minNoDigits(常量前缀*p,int区域);
bool已注册(常量前缀*p,int区域,常量字符*publisher);
// .. 文件的其余部分

只需切换头的顺序,代码就可以正常编译。由于您没有提供
GS1Prefix.cpp
EAN.cpp
我无法对其余错误(如果还有任何错误)发表评论

#包括
//GS1Prefix.h
常数int MAX=700;
结构前缀{
int no;//条目数
int区域[MAX];//区域元素
char pubLow[MAX][8];//发布服务器范围的低端
char pubHgh[MAX][8];//发行商范围的高端
int pubLen[MAX];//发布者字符串中的字符数
};
//EAN.h
bool是有效的(const char*str);
bool已注册(常量前缀*p,常量字符*str,字符区域[],字符发布者[],字符标题[]);
//a1test.cpp
bool load(常量字符*文件名,前缀*p);
bool已注册(常量前缀*p,int区域);
int minNoDigits(常量前缀*p,int区域);
bool已注册(常量前缀*p,int区域,常量字符*publisher);
// .. 文件的其余部分

只需切换头的顺序,代码就可以正常编译。由于您没有提供
GS1Prefix.cpp
EAN.cpp
我无法对其余错误(如果还有任何错误)发表评论

#包括
//GS1Prefix.h
常数int MAX=700;
结构前缀{
int no;//条目数
int区域[MAX];//区域元素
char pubLow[MAX][8];//发布服务器范围的低端
char pubHgh[MAX][8];//发行商范围的高端
int pubLen[MAX];//发布者字符串中的字符数
};
//EAN.h
bool是有效的(const char*str);
bool已注册(常量前缀*p,常量字符*str,字符区域[],字符发布者[],字符标题[]);
//a1test.cpp
bool load(常量字符*文件名,前缀*p);
bool已注册(常量前缀*p,int区域);
int minNoDigits(常量前缀*p,int区域);
bool已注册(常量前缀*p,int区域,常量字符*publisher);
// .. 文件的其余部分

头文件应包含足够的定义,以便它们能够自给自足。在这种情况下,您需要提供必需类型Prefix的定义。只需将include添加到EAN.h的顶部:

#include <GS1Prefix.h>
bool isValid(const char* str);
bool isRegistered(const Prefix* p, const char* str, char area[],char publisher[],
                  char title[]);
#包括
bool是有效的(const char*str);
bool已注册(常量前缀*p、常量字符*str、字符区域[]、字符发布者[]、字符,
字符标题[]);

然后,您可以在任何源文件中包含EAN.h,因为您不需要担心依赖关系。

头文件应该包含足够的定义,以便它们是自给自足的。在这种情况下,您需要提供必需类型Prefix的定义。只需将include添加到EAN.h的顶部:

#include <GS1Prefix.h>
bool isValid(const char* str);
bool isRegistered(const Prefix* p, const char* str, char area[],char publisher[],
                  char title[]);
#包括
bool是有效的(const char*str);
bool已注册(常量前缀*p、常量字符*str、字符区域[]、字符发布者[]、字符,
字符标题[]);

然后,您可以在任何源文件中包含EAN.h,因为您不需要担心依赖关系。

头文件应该包含足够的定义,以便它们是自给自足的。在这种情况下,您需要提供必需类型Prefix的定义。只需将include添加到EAN.h的顶部:

#include <GS1Prefix.h>
bool isValid(const char* str);
bool isRegistered(const Prefix* p, const char* str, char area[],char publisher[],
                  char title[]);
#包括
bool是有效的(const char*str);
bool已注册(常量前缀*p、常量字符*str、字符区域[]、字符发布者[]、字符,
字符标题[]);

然后,您可以在任何源文件中包含EAN.h,因为您不需要担心依赖关系。

头文件应该包含足够的定义,以便它们是自给自足的。在这种情况下,您需要提供必需类型Prefix的定义。只需将include添加到EAN.h的顶部:

#include <GS1Prefix.h>
bool isValid(const char* str);
bool isRegistered(const Prefix* p, const char* str, char area[],char publisher[],
                  char title[]);
#包括
bool是有效的(const char*str);
布尔