We're updating the issue view to help you get more done. 

CGNS Global variables conflicting with application objects

Description

In cgns_internals.c, there are a number of global variables defined:

int Idim; /* current IndexDimension */
int Cdim; /* current CellDimension */
int Pdim; /* current PhysicalDimension */
cgsize_t CurrentDim[9]; /* current vertex, cell & bnd zone size*/
CGNS_ENUMT( ZoneType_t ) CurrentZoneType; /* current zone type */
int NumberOfSteps; /* Number of steps */

In my case I an building CGNS with the Intel compiler under Linux and then a shared library that links to the CGNS library that I dynamically load into my application. The problem I am running into is that 'Idim' is being "leaked" into the global namespace and by chance conflicted with an identically named object of a different type in the application. It did not look like Idim was used outside of this file and it was not noted to be extern in the cgns header files. My workaround to this issue is to make these variables 'static' like this:

static int Idim; /* current IndexDimension */
static int Cdim; /* current CellDimension */
static int Pdim; /* current PhysicalDimension */
static cgsize_t CurrentDim[9]; /* current vertex, cell & bnd zone size*/
static CGNS_ENUMT( ZoneType_t ) CurrentZoneType; /* current zone type */
static int NumberOfSteps; /* Number of steps */

Is this a reasonable patch? If so, I can put in a pull request for it If not, what am I breaking with the patch as I have been using it for some time now.

Environment

Linux, Intel compiler.

Status

Assignee

Randall Frank

Reporter

Randall Frank

Labels

None

Components

Affects versions

3.3.1

Priority

Major