Message: Compiling Problem - error: expected unqualified-id before "namespace" Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Compiling Problem - error: expected unqualified-id before "namespace" 

Keywords: compile error
Forum: Installation and Configuration
Date: 16 Aug, 2007
From: Jamie Robinson <j.robinson@physics.gla.ac.uk>

Hello all

When trying to compile my code for a novice photon energy tagger I am met with the following repetitive error. The following is a small section of this error (the full error would take up too much space)

Making dependency for file src/TaggerSD.cc ...
Making dependency for file src/TaggerDetectorConstruction.cc ...
Compiling TaggerDetectorConstruction.cc ...
In file included from /cern/geant4/geant4.8.2/source/track/include/G4Step.hh:65,
                 from /cern/geant4/geant4.8.2/source/digits_hits/detector/include/G4VSensitiveDetector.hh:35,
                 from include/TaggerSD.hh:4,
                 from src/TaggerDetectorConstruction.cc:3:
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/iomanip:49: error: expected unqualified-id before "namespace"
In file included from /cern/geant4/geant4.8.2/source/global/management/include/G4ThreeVector.hh:41,
                 from /cern/geant4/geant4.8.2/source/track/include/G4Step.hh:67,
                 from /cern/geant4/geant4.8.2/source/digits_hits/detector/include/G4VSensitiveDetector.hh:35,
                 from include/TaggerSD.hh:4,
                 from src/TaggerDetectorConstruction.cc:3:
/cern/clhep/2.0.3.1/include/CLHEP/Vector/ThreeVector.h:31: error: expected unqualified-id before "namespace"
In file included from /cern/clhep/2.0.3.1/include/CLHEP/Vector/ThreeVector.h:445,
                 from /cern/geant4/geant4.8.2/source/global/management/include/G4ThreeVector.hh:41,
                 from /cern/geant4/geant4.8.2/source/track/include/G4Step.hh:67,
                 from /cern/geant4/geant4.8.2/source/digits_hits/detector/include/G4VSensitiveDetector.hh:35,
                 from include/TaggerSD.hh:4,
                 from src/TaggerDetectorConstruction.cc:3:
/cern/clhep/2.0.3.1/include/CLHEP/Vector/ThreeVector.icc:13: error: expected unqualified-id before "namespace"
In file included from /cern/geant4/geant4.8.2/source/track/include/G4Step.hh:67,
                 from /cern/geant4/geant4.8.2/source/digits_hits/detector/include/G4VSensitiveDetector.hh:35,
                 from include/TaggerSD.hh:4,
                 from src/TaggerDetectorConstruction.cc:3:
/cern/geant4/geant4.8.2/source/global/management/include/G4ThreeVector.hh:43: error: ISO C++ forbids declaration of `Hep3Vector' with no type
/cern/geant4/geant4.8.2/source/global/management/include/G4ThreeVector.hh:43: error: expected `;' before "G4ThreeVector"

See below the relevant pieces of code TaggerSD.hh and TaggerDetectorConstruction.cc

#ifndef TaggerSD_h
#define TaggerSD_h 1

#include "G4VSensitiveDetector.hh"
#include "globals.hh"

class G4TouchableHistory; class G4HCofThisEvent; class G4Step;

#include "TaggerHit.hh"

class TaggerSD : public G4VSensitiveDetector { public:

  TaggerSD(G4String,G4int);
  ~TaggerSD();

  void Initialize(G4HCofThisEvent*);
  G4bool ProcessHits(G4Step* astep,G4TouchableHistory*);
  void EndOfEvent(G4HCofThisEvent*);
  void clear();
  void DrawAll();
  void PrintAll();

private:
    TaggerHitsCollection *TaggerCollection; // General array of TaggerHits (from TwistHit.hh)

};

#endif

#include "TaggerDetectorConstruction.hh"
#include "TaggerDetectorMessenger.hh"
#include "TaggerSD.hh"

#include "G4UniformMagField.hh"
#include "G4FieldManager.hh"
#include "G4ChordFinder.hh"
#include "G4TransportationManager.hh"
#include "G4Mag_UsualEqRhs.hh"

#include "G4NistManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4SDManager.hh"
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
#include "G4Tubs.hh"
#include "G4Cons.hh"
#include "G4Material.hh"

TaggerDetectorConstruction::TaggerDetectorConstruction(){

  fWorldPhysi=NULL;
  fRadiatorPhysi=NULL
  fFieldVolPhysi=NULL;
  fFPAPhysi=NULL;
  fMainCollPhysi=NULL;
  fPostCollPhysi=NULL;
  fPbGlassPhysi=NULL;

 detectorMessenger=new TaggerDetectorMessenger(this);

 fRadiatorMaterial=NULL;
 fRadZ=0*cm;
 fColRad=0*cm;

 // read the set up file TaggerSetup.mac
 // get the pointer to the User Interface manager 

 G4UImanager* UI = G4UImanager::GetUIpointer();
  G4String command = "/control/execute macros/TaggerSetup.mac";
  UI->ApplyCommand(command);
}

TaggerDetectorConstruction::~TaggerDetectorConstruction()
{
  delete detectorMessenger;

}

G4VPhysicalVolume* TaggerDetectorConstruction::Construct() {

  Materials();
  //------------------------------------------------------ volumes

  //------------------------------ experimental hall (world volume)
  //------------------------------ beam line along z axis

  G4double world_x = 20.0*m;
  G4double world_y = 20.0*m;
  G4double world_z = 20.0*m;
  fWorld  = new G4Box("World Box",world_x,world_y,world_z);
  fWorldLogic = new G4LogicalVolume(fWorld,G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"),"World Logical Volume");
  fWorldPhysi = new G4PVPlacement(0,G4ThreeVector(0,0,0),fWorldLogic,"Physi World",0,false,0);

  MakeTagger();
  //                                        
  return WorldPhysi;
}

void TaggerDetectorConstruction::MakeTagger(){

 MakeRadiator();
 MakeFieldVol();

 MakeFPA();
 MakeMainCol();
 MakePostCol();
 MakePbGlass();

}

void TaggerDetectorConstruction::MakeRadiator(){
  //Make radiator, use TaggerDetectorMessenger to choose fRadiatorMaterial etc

  if (fRadiatorMaterial==G4_Cu) {fRadZ=5*micron;}

  else if (fRadiatorMaterial==G4_Ta){fRadZ=4*micron;}

  else if (fRadiatorMaterial==G4_C){fRadZ=50*micron;}

  else if (fRadiatorMaterial==G4_Ni){
    G4cout<<"fRadZ should be either 2*micron or 62.5*micron, please specify in macros/TaggerSetup"<<G4endl;

    G4cout<<"You have chosen radiator material "<<fRadiatorMaterial<<" with thickness "<<fRadZ<<G4endl;

 fRadiator=new G4Box("RAD",1*cm,1*cm,fRadZ);
  fRadiatorLogic=new G4LogicalVolume(fRadiator,fRadiatorMaterial,"RAD")
    fRadiatorPhysi=new G4PVPlacement(0,G4ThreeVector(0,0,0),
	     		     fRadiatorLogic,"RadiatorPhysical",fWorldLogic,false,0); 

  G4VisAttributes* rad_visatt = new G4VisAttributes();
  rad_visatt->SetColor(G4Color(0,1,0));
  fRadiatorLogic->SetVisAttributes(rad_visatt);

  }

void TaggerDetectorConstruction::MakeFieldVol(){

  //MAKE LOCAL B FIELD IN THE VOLUME

  G4double fieldValue; // = 2.*tesla;

  G4UniformMagField* intField
    = new G4UniformMagField(G4ThreeVector(0.,fieldValue,0.));

  G4Mag_UsualEqRhs* iEquation = new G4Mag_UsualRhs(intField);

  G4MagIntegratorStepper* iStepper = new G4ClassicalRK4(iEquation);

  G4ChordFinder* iChordFinder = new G4ChordFinder(intField,1.0e-2*mm,iStepper);

  G4FieldManager* fieldMgr = new G4FieldManager(intField,iChordFinder);

//Make volume where B field is applied deflectin recoil electrons from the radiator

  G4double field_vol_x=1000*mm;
  G4double field_vol_y=12.5*mm;
  G4double field_vol_z=1000*mm;
  fFieldVol = new G4Box("Field Volume",field_vol_x,field_vol_y,field_vol_z);
  fFieldVolLogic =  new G4LogicalVolume(fFieldVol,G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"),"Field Volume Logic",fieldMgr,0,0);
  fFieldVolPhysi=new G4PVPlacement(0,G4ThreeVector(800*mm,0,1020*mm),
                               fFieldVolLogic,"Field Vol Physi",fWorldLogic,false,0);

}

void TaggerDetectorConstruction::MakeFPA(){
  //Make Focal Plane Array detector to detect recoil electrons (Need Sensitive Detector
  G4double scint_x = 6.5*mm;
  G4double scint_y = 1*mm;
    G4double scint_z =875*mm;

    fFPA = new G4Box("Focal Plane Array",scint_x,scint_y,scint_z);
    fFPALogic = new G4LogicalVolume(fFPA,G4NistManager::Instance()->FindOrBuildMaterial("G4_PLASTIC_SC_VINYLTOLUENE"),"FPA Logic");
    fFPAPhysi = new G4PVPlacement(0,G4ThreeVector(1820*mm,0,895*mm),
                               fFPALogic,"FPA Physi",fWorldLogic,false,0);

    G4SDManager* SDman = G4SDManager::GetSDMpointer();
	  G4String taggerSDname = "/mydet/tagger";
	  TaggerSD* taggerSD = new TaggerSD(taggerSDname);
	  SDman->AddNewDetector(taggerSD);
	  fFPALogic->SetSensitiveDetector(taggerSD);

	  G4VisAttributes* fpa_visatt = new G4VisAttributes();
	  fpa_visatt->SetColor(G4Color(1,0,0));
	  fFPALogic->SetVisAttributes(fpa_visatt);

}

void TaggerDetectorConstruction::MakeMainCol(){
  //Make the variable main photon collimator

  G4cout<<"You have chosen the radius of the main collimator as "<<fColRad<<G4endl;

  G4double fColRad;
  G4double maincol_rmax=10*mm;
  G4double maincol_z=90*mm; //half length

  fMainCol = new G4Tub("Post Collimator",fColRad,maincol_rmax,maincol_z,0*deg,360*deg);
  fMainColLogic = new G4LogicalVolume(fMainCol,G4NistManager::Instance()->FindOrBuildMaterial("G4_Pb"),"Main collimator logic");
  fMainColPhysi = new G4PVPlacement(0,G4ThreeVector(0,0,2370*mm),
	     	    fMainColLogic,"Main Collimator Physi",fWorldLogic,false,0);

  G4VisAttributes* col_visatt = new G4VisAttributes();
  col_visatt->SetColor(G4Color(1,1,1));
  fMainColLogic->SetVisAttributes(col_visatt);

}

void TaggerDetectorConstruction::MakePostCol(){
  //Make the Pb post collimator
  G4double postcol_rmin=8*mm;
  G4double postcol_rmax=25*mm;
  G4double postcol_z=75*mm; //half length

  fPostCol = new G4Tub("Post Collimator",postcol_rmin,postcol_rmax,postcol_z,0*deg,360*deg);
  fPostColLogic = new G4LogicalVolume(fPostCol,G4NistManager::Instance()->FindOrBuildMaterial("G4_Pb"),"Post collimator logic");
  fPostColPhysi = new  G4PVPlacement(0,G4ThreeVector(0,0,5525*mm),
	     	    fPostColLogic,"Post Collimator Physi",fWorldLogic,false,0);

`
    G4VisAttributes* col_visatt = new G4VisAttributes();
    col_visatt->SetColor(G4Color(1,1,1));
    fPostColLogic->SetVisAttributes(col_visatt);
}

void TaggerDetectorConstruction::MakePbGlass(){
  //Make the PbGlass Detector will increment each time a photon is detected
  G4double pb_glass_x=100*mm;
  G4double pb_glass_y=100*mm;
  G4double pb_glass_z=100*mm;

  fPbGlass = new G4Box("Lead Glass",pb_glass_x,pb_glass_y,pb_glass_z);
  fPbGlassLogic = new G4LogicalVolume(fPbGlass,G4NistManager::Instance()->FindOrBuildMaterial("G4_GLASS_LEAD"),"PbGlassLogic");
  fPbGlassPhysi = new G4PVPlacement(0,G4ThreeVector(0,0,19800*mm),
				  fPbGlassLogic,"Lead Glass Physi",fWorldLogic,false,0);
  G4SDManager* SDman = G4SDManager::GetSDMpointer();
	  G4String taggerSDname = "/mydet/tagger";
	  TaggerSD* taggerSD = new TaggerSD(taggerSDname);
	  SDman->AddNewDetector(taggerSD);
	  fPbGlassLogic->SetSensitiveDetector(taggerSD);

	  G4VisAttributes* pb_visatt = new G4VisAttributes();
	  pb_visatt->SetColor(G4Color(0,0,1));
	  fPbGlassLogic->SetVisAttributes(pb_visatt)
}

void TaggerDetectorConstruction::UpdateGeometry() {

G4RunManager::GetRunManager()->DefineWorldVolume(Construct()); }

Does anyone have any ideas of the source of this error.

Thanks in advance. Jamie

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Compiling Problem - error: expected unqualified-id before "namespace"   (Ben Morgan - 17 Aug, 2007)
(_ None: Re: Compiling Problem - error: expected unqualified-id before "namespace"   (Jamie Robinson - 26 Sep, 2007)
 Add Message Add Message
to: "Compiling Problem - error: expected unqualified-id before "namespace""

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]