I am writing an adaptive step size update algorithm in OpenSees (an opensource earthquake engineering simulation project written majorly in visual studio c++). I am facing a conflict between two variables having the same name in two different header files (namely, windef.h and steelz01.h). I need a way to resolve this conflict.
I am using gnuplot-iostream.h in my project, I am facing this conflict only when I include this header file, otherwise there is no conlfict, code is builidng perfectly.
Basically gnuplot-iostream.h is calling windows.h, which is further calling windef.h. I have added include gauards in steelz01.h file, but it did not resolve the issue.
When I change the varaibale name in steelz01.h to a different name, then also the code is perfectly building. No ISSUE found. But, I don't want to channge the name of the variable in steelz01, it has serious repercussions.
I am including header files like this
#include "gnuplot-iostream.h"
#include <SteelZ01.h>
This is how the variable SIZE is defined in steelz01
#define LOOP_NUM_LIMIT 30
const int SIZE = LOOP_NUM_LIMIT; //limit of array number
and in windef.h, it is defined like this
typedef struct tagSIZE
{
LONG cx;
LONG cy;
} SIZE, *PSIZE, *LPSIZE;
typedef SIZE SIZEL;
typedef SIZE *PSIZEL, *LPSIZEL;
Visual Studio 2017 is throwing this error,
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'
I am expecting a way to resolve this conflict and a successful build.
I would suggest you to put include statement in namespace,
namespace ABC
{
#include "gnuplot-iostream.h"
}
namespace PQR
{
#include <SteelZ01.h>
}
Call:
ABC::SIZE
PQR::SIZE
This will not change any code of existing libraries. However, author of library using common names hence suggest him to keep common name under namespace to reduce any conflict.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With