Redefinition of Symbol: #pragma once

I’m trying to compile a code that has several .h files and there are redefinitions in the .h files.
Does PGI 10.3 (C compiler) support #pragma once ?

pgcc -D_UMFPACK -DWINDOWS -D_PC_PG -lstdc++ -I…/include -I…/frict
PGC-S-0043-Redefinition of symbol, NSM_SEDIMENT_SORBING_ENUM (.\C.En
PGC-S-0043-Redefinition of symbol, NSM_PARTITIONABLE_ENUM (.\C.Enume
PGC-S-0043-Redefinition of symbol, NSM_SPECIES_ENUM (.\C.Enumeration
PGC/x86-64 Windows 10.3-0: compilation completed with severe errors
make[1]: *** […/lib/libadh.a(C.Q2.Channel.Cell.Kinetics.o)] Error 2

Thanks
Gaurav

Hi Gaurav,

Does PGI 10.3 (C compiler) support #pragma once ?

No sorry. You’ll need to add the standard pre-possessor guards.

  • Mat

Mat,

Thanks for the quick reply.
I added #ifndef pre-processor blocks and I no longer get the redifinition errors.
However (and I’m new to enums so, this might be wrong) I get the following error

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword enum (.\C.App.h: 57)
PGC-S-0037-Syntax error: Recovery attempted by deleting keyword enum (.\C.Sediment.h: 57)
PGC-S-0037-Syntax error: Recovery attempted by deleting keyword enum (.\C.Enumerations.h: 57)

C.ENUMERATIONS.h is

#include “LINKAGE.h”


#ifndef
#define NSM_SEDIMENT_SORBING_ENUM
enum NSM_SEDIMENT_SORBING_ENUM
{
NSM_SEDIMENT_IS_SORBING_Enum,
NSM_SEDIMENT_IS_NOT_SORBING_Enum
};
#endif

#ifndef NSM_PARTITIONABLE_ENUM
#define NSM_PARTITIONABLE_ENUM
enum NSM_PARTITIONABLE_ENUM
{
NSM_IS_PARTITIONABLE_Enum, // Use if: Want partitioning between dissolved, bound and sediment-sorbed
NSM_IS_FULLY_DISSOLVED_Enum, // Use if: Want only dissolved form
NSM_IS_FULLY_SORBED_Enum // Use if: Want only sediment-sorbed form
};
#endif

#ifndef NSM_SPECIES_ENUM
#define NSM_SPECIES_ENUM
enum NSM_SPECIES_ENUM
{
NSM_NO2_Enum = 0,
NSM_NO3_Enum,
NSM_NH4_Enum,
NSM_ORGANIC_NITROGEN_Enum,
NSM_ORGANIC_PHOSPHORUS_Enum,
NSM_DISSOLVED_PHOSPHORUS_Enum,
NSM_ALGAE_Enum,
NSM_CBOD_Enum,
NSM_DISSOLVED_OXYGEN_Enum,
NSM_Soil_N_organicActive_Enum = 100,
NSM_Soil_N_organicStable_Enum,
NSM_Soil_P_organicActive_Enum,
NSM_Soil_P_organicStable_Enum,
NSM_Soil_P_mineralActive_Enum,
NSM_Soil_P_mineralStable_Enum,
};
#endif



// F U N C T I O N P R O T O T Y P E S

EXPORT int NSM_SPECIES_ENUM_IsChannelSpecie(enum NSM_SPECIES_ENUM specieEnum);

EXPORT int NSM_SPECIES_ENUM_IsOverlandSpecie(enum NSM_SPECIES_ENUM specieEnum);

EXPORT int NSM_SPECIES_ENUM_IsSoilSpecie(enum NSM_SPECIES_ENUM specieEnum);

EXPORT enum NSM_PARTITIONABLE_ENUM NSM_SPECIES_ENUM_IsPartitionable(enum NSM_SPECIES_ENUM specieEnum);

The last line is line 57.
Any help on why line 57 is causing errors will be appreciated.

Thanks
Gaurav

Looks like a typo where you missed adding NSM_SEDIMENT_SORBING_ENUM after the ifdef.

#ifndef NSM_SEDIMENT_SORBING_ENUM 
#define NSM_SEDIMENT_SORBING_ENUM 
enum NSM_SEDIMENT_SORBING_ENUM 
{

Are you getting the redefinition errors because ENUMERATIONS.h is getting included multiple times? If so, then you probably can just put a guard around the whole file. Something like:

#ifndef ENUMERATIONS_H_DEFINE
#define ENUMERATIONS_H_DEFINE

#include "LINKAGE.h" 

enum NSM_SEDIMENT_SORBING_ENUM 
{ 
NSM_SEDIMENT_IS_SORBING_Enum, 
NSM_SEDIMENT_IS_NOT_SORBING_Enum 
}; 

enum NSM_PARTITIONABLE_ENUM 
{ 
NSM_IS_PARTITIONABLE_Enum, // Use if: Want partitioning between dissolved, bound and sediment-sorbed 
NSM_IS_FULLY_DISSOLVED_Enum, // Use if: Want only dissolved form 
NSM_IS_FULLY_SORBED_Enum // Use if: Want only sediment-sorbed form 
}; 
enum NSM_SPECIES_ENUM 
{ 
NSM_NO2_Enum = 0, 
NSM_NO3_Enum, 
NSM_NH4_Enum, 
NSM_ORGANIC_NITROGEN_Enum, 
NSM_ORGANIC_PHOSPHORUS_Enum, 
NSM_DISSOLVED_PHOSPHORUS_Enum, 
NSM_ALGAE_Enum, 
NSM_CBOD_Enum, 
NSM_DISSOLVED_OXYGEN_Enum, 
NSM_Soil_N_organicActive_Enum = 100, 
NSM_Soil_N_organicStable_Enum, 
NSM_Soil_P_organicActive_Enum, 
NSM_Soil_P_organicStable_Enum, 
NSM_Soil_P_mineralActive_Enum, 
NSM_Soil_P_mineralStable_Enum, 
}; 

// F U N C T I O N P R O T O T Y P E S 

EXPORT int NSM_SPECIES_ENUM_IsChannelSpecie(enum NSM_SPECIES_ENUM specieEnum); 

EXPORT int NSM_SPECIES_ENUM_IsOverlandSpecie(enum NSM_SPECIES_ENUM specieEnum); 

EXPORT int NSM_SPECIES_ENUM_IsSoilSpecie(enum NSM_SPECIES_ENUM specieEnum); 

EXPORT enum NSM_PARTITIONABLE_ENUM NSM_SPECIES_ENUM_IsPartitionable(enum NSM_SPECIES_ENUM specieEnum); 

#endif /* ENUMERATIONS_H_DEFINE */