Message: Re: How do I efficiently surpress unused variable warning caused by physical volumes? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: How do I efficiently surpress unused variable warning caused by physical volumes? 

Forum: Geometry
Re: Question How do I efficiently surpress unused variable warning caused by physical volumes? (Alex Leatherland)
Date: 08 Feb, 2016
From: Michael H. Kelsey <Michael H. Kelsey>

On Mon, 08 Feb 2016 10:30:53 GMT, Alex Leatherland wrote:
> During compling I see a lot of [-Wunused-but-set-variable] warning messages caused by physical volumes in my detector construction. For example.
> 
>    warning: variable 'myvol_phys' set but not used [-Wunused-but-set-variable]
> 
> How do I stop this happening?

The easiest way is to just not assign the pointer to anything. You aren't allowed to ever delete it -- the placement self-registers into the geometry store, and will be deleted by G4 when the geometry is cleared. so in your code, just do

  G4LogicalVolume* myvol = new G4LogicalVolume(<whatever>);
  myvol->SetVisAttributes() ... or whatever other stuff you want to do
  new G4PVPlacement(...);

You won't get any warnings.

  -- Michael Kelsey

 Add Message Add Message
to: "Re: How do I efficiently surpress unused variable warning caused by physical volumes?"

 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 ]