PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Redefinition of Symbol: #pragma once

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
GauravSavant/CHL33655



Joined: 06 Apr 2010
Posts: 8

PostPosted: Sat Jun 09, 2012 10:06 am    Post subject: Redefinition of Symbol: #pragma once Reply with quote

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 ?

Quote:

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
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6218
Location: The Portland Group Inc.

PostPosted: Mon Jun 11, 2012 8:53 am    Post subject: Reply with quote

Hi Gaurav,

Quote:
Does PGI 10.3 (C compiler) support #pragma once ?
No sorry. You'll need to add the standard pre-possessor guards.

- Mat
Back to top
View user's profile
GauravSavant/CHL33655



Joined: 06 Apr 2010
Posts: 8

PostPosted: Tue Jun 12, 2012 2:05 pm    Post subject: Reply with quote

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

Quote:

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
Quote:

#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
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6218
Location: The Portland Group Inc.

PostPosted: Tue Jun 12, 2012 4:08 pm    Post subject: Reply with quote

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

#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:

Code:
#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 */
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group