我有 2 个字符串数组,它们在头文件中定义,如下所示:
#ifndef DRC_DefinesH
#define DRC_DefinesH
#include <string>
#include <System.hpp>
//---------------------------------------------------------------------------
std::string MagFields[] = {
"SCAN", "EVENT", "EVENT2", "EVENT1", "EVENT3", "VECTORX", "VECTORY", "VECTORZ", "MAG1RAW", "MAG2RAW", "MAG3RAW",
"MAG4RAW", "MAG1UNCOMP", "MAG2UNCOMP", "MAG3UNCOMP", "MAG4UNCOMP", "MAG1COMP", "MAG2COMP", "MAG3COMP", "MAG4COMP",
"GRAD1", "GRAD2", "GRAD3", "UTC", "LAT", "LON", "ALT", "ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4", "SYSTIME"};
std::string AnalogFields[] = {
"SCAN", "EVENT0", "EVENT1", "EVENT2", "EVENT3", "ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4", "ANALOG5", "ANALOG6",
"ANALOG7", "ANALOG8", "ANALOG9", "ANALOG10", "ANALOG11", "ANALOG12", "ANALOG13", "ANALOG14", "ANALOG15", "ANALOG16",
"ANALOG17", "ANALOG18", "ANALOG19", "ANALOG20", "ANALOG21", "ANALOG22", "ANALOG23", "ANALOG24", "ANALOG25",
"ANALOG26", "ANALOG27", "ANALOG28", "ANALOG29", "ANALOG30", "ANALOG31", "ANALOG32"};
... other stuff
#endif
此标头包含许多其他内容,并且间接包含在 C++ Builder XE2 项目的每个单元中。当我构建项目时,我收到很多链接器警告,指出
"public symbol _MagFields and _AnalogFields are defined in both modules AAA and BBB"
其中 AAA 和 BBB 依次是项目中的每个单元组合。
这些特定的声明可以移动到一个单元的实现端并且警告消失,但我想了解为什么它是必要的。Embarcadero 文档只是告诉我如何摆脱警告,而不是它的含义。