# Header guard missing in G4TMagFieldEquation.hh?

**URL:** <https://geant4-forum.web.cern.ch/t/header-guard-missing-in-g4tmagfieldequation-hh/13787>\
**Category:** Ideas and Requirements\
**Created:** [March 11, 2025, 3:49am UTC](https://geant4-forum.web.cern.ch/t/header-guard-missing-in-g4tmagfieldequation-hh/13787 "2025-03-11T03:49:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhao\_Shihan](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/zhao_shihan/32/4521_2.png) [@Zhao\_Shihan](https://geant4-forum.web.cern.ch/u/Zhao_Shihan)\
**Post date:** [March 11, 2025, 3:49am UTC](https://geant4-forum.web.cern.ch/t/header-guard-missing-in-g4tmagfieldequation-hh/13787/1 "2025-03-11T03:49:28Z")

</div>

I noticed that header guard is missing in G4TMagFieldEquation.hh:

```auto
//
// ********************************************************************
// * License and Disclaimer *
// *                                     
(...)
// Adapted from G4Mag_UsualEqRhs
//
// #include "G4ChargeState.hh"
#include "G4Mag_UsualEqRhs.hh"

template
<class T_Field>
class G4TMagFieldEquation : public G4Mag_UsualEqRhs
(...)
  // Dependent objects
  T_Field *itsField;
};
(EOF)

```

It causes redefinition of class template `G4TMagFieldEquation` when `G4TMagFieldEquation.hh` is included multiple times. This issue cannot be avoided by explicitly include only once in some case, e.g. combining multiple geant4 apps in a single executable with [unity build](https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html) as in my case, even if only one `G4TMagFieldEquation.hh` is included in each app.

I suggest adding a header guard to resolve this issue.

Thanks,  
SHZhao

---

<div class="post-metadata">

**Author:** ![gcosmo](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/gcosmo/32/102_2.png) [@gcosmo](https://geant4-forum.web.cern.ch/u/gcosmo)\
**Post date:** [March 11, 2025, 7:36am UTC](https://geant4-forum.web.cern.ch/t/header-guard-missing-in-g4tmagfieldequation-hh/13787/2 "2025-03-11T07:36:56Z")

</div>

Thanks. This is now fixed in the upstream repository.

---

<div class="post-metadata">

**Author:** ![Zhao\_Shihan](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/zhao_shihan/32/4521_2.png) [@Zhao\_Shihan](https://geant4-forum.web.cern.ch/u/Zhao_Shihan)\
**Post date:** [March 11, 2025, 10:27am UTC](https://geant4-forum.web.cern.ch/t/header-guard-missing-in-g4tmagfieldequation-hh/13787/3 "2025-03-11T10:27:14Z")

</div>

Quick reply! Thanks!
