【发布时间】:2011-07-19 05:31:54
【问题描述】:
我以为ifndef something #define something body #endif 解决了这个错误,所以我不确定为什么会这样。
//Library.h
#ifndef __LIBRARY__
#define __LIBRARY__
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdarg>
#include <vector>
#include <ctime>
#include <cmath>
#include <cstdlib>
//file includes
#include "Globals.h"
using namespace std;
#endif //__LIBRARY__
--
//globals.h
//global variables
#ifndef __GLOBAL__
#define __GLOBAL__
#include <vector>
#include <iostream>
#include <string>
//prototypes
bool Poglathon(std::vector<std::string>& text);
void NPCTalk(std::string const& speaker,std::vector<std::string> const& text);
void wait(double seconds);
//player stats
std::string name;
double str; //strength
double wis; //wisdom
double ref; //reflex
double hp; //health points
double i; //initiative
double inte; //intelligence
double c; //courage
int gold; //gold
int xp; //experience
int ap; //armour points
int wd; //weapon damage
int lvl; //level
int sp; //skill points
#endif //__GLOBAL__
还有另外两个包含“Library.h”的 cpp 文件。
【问题讨论】:
-
不相关:带有双下划线的标识符是reserved for the compiler。
-
多重定义符号是哪一个?
-
不相关:需要对其名称进行注释的标识符可能没有正确命名。