我正在 OpenSees(一个主要用 Visual Studio C++ 编写的开源地震工程模拟项目)中编写自适应步长更新算法。我面临两个不同头文件中具有相同名称的两个变量之间的冲突(即windef.h and 钢Z01.h)。我需要一种方法来解决这个冲突。
我在用gnuplot-iostream.h在我的项目中,只有当我包含此头文件时,我才会遇到此冲突,否则不存在冲突,代码构建完美。
基本上gnuplot-iostream.h正在打电话窗口.h,进一步调用windef.h。我在steelz01.h文件中添加了include gauards,但它没有解决问题。
当我将 Steelz01.h 中的 varaibale 名称更改为其他名称时,代码也完美构建。未发现问题。但是,我不想更改 Steelz01 中变量的名称,它会产生严重的影响。
我包括这样的头文件
#include "gnuplot-iostream.h"
#include <SteelZ01.h>
这就是 Steelz01 中变量 SIZE 的定义方式
#define LOOP_NUM_LIMIT 30
const int SIZE = LOOP_NUM_LIMIT; //limit of array number
在windef.h中,它是这样定义的
typedef struct tagSIZE
{
LONG cx;
LONG cy;
} SIZE, *PSIZE, *LPSIZE;
typedef SIZE SIZEL;
typedef SIZE *PSIZEL, *LPSIZEL;
Visual Studio 2017 抛出此错误,
1>c:\program files (x86)\windows kits\8.1\include\shared\windef.h(190): error C2378: 'SIZE': redefinition; symbol cannot be overloaded with a typedef
1>e:\phd working folder\0_ops_github\src\material\nd\reinforcedconcreteplanestress\steelz01.h(17): note: see declaration of 'SIZE'
我期待有一种方法来解决这个冲突并成功构建。