Error: "expected ‘:’, ‘,’, ‘;’, ‘}’ " and "struct has no member named"
Error: "expected ‘:’, ‘,’, ‘;’, ‘}’ " and "struct has no member named"
我找不到任何遗漏的括号。有什么问题?
#ifndef PROCINFO_H_
#define PROCINFO_H_
#include <linux/limits.h>
#include <elf.h>
enum boolean {f,t};
typedef struct {
enum boolean fileHdr = 0;
enum boolean programHdr=0;
enum boolean sectionHdr = 0;
enum boolean info = 0;
enum boolean def = 0;
} procInfo;
typedef struct {
char filename[NAME_MAX];
procInfo info;
} procFile;
#endif /* PROCINFO_H_ */
错误:
expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
make: *** [src/subdir.mk:20: src/elfViewer.o] Error 1
您不能在 typedef 声明中初始化 C 中结构的数据成员,因为您正在这样做
typedef struct {
enum boolean fileHdr = 0;
enum boolean programHdr=0;
enum boolean sectionHdr = 0;
enum boolean info = 0;
enum boolean def = 0;
} procInfo;
你需要写
typedef struct {
enum boolean fileHdr;
enum boolean programHdr;
enum boolean sectionHdr;
enum boolean info;
enum boolean def;
} procInfo;
定义此类对象时,您可以为其提供初始化,例如
pricinfo info = { 0 };
我找不到任何遗漏的括号。有什么问题?
#ifndef PROCINFO_H_
#define PROCINFO_H_
#include <linux/limits.h>
#include <elf.h>
enum boolean {f,t};
typedef struct {
enum boolean fileHdr = 0;
enum boolean programHdr=0;
enum boolean sectionHdr = 0;
enum boolean info = 0;
enum boolean def = 0;
} procInfo;
typedef struct {
char filename[NAME_MAX];
procInfo info;
} procFile;
#endif /* PROCINFO_H_ */
错误:
expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
make: *** [src/subdir.mk:20: src/elfViewer.o] Error 1
您不能在 typedef 声明中初始化 C 中结构的数据成员,因为您正在这样做
typedef struct {
enum boolean fileHdr = 0;
enum boolean programHdr=0;
enum boolean sectionHdr = 0;
enum boolean info = 0;
enum boolean def = 0;
} procInfo;
你需要写
typedef struct {
enum boolean fileHdr;
enum boolean programHdr;
enum boolean sectionHdr;
enum boolean info;
enum boolean def;
} procInfo;
定义此类对象时,您可以为其提供初始化,例如
pricinfo info = { 0 };