# Error: reference to ‘Medium’ is ambiguous

**URL:** <https://root-forum.cern.ch/t/error-reference-to-medium-is-ambiguous/64272>\
**Category:** Garfield++\
**Created:** [October 2, 2025, 9:20am UTC](https://root-forum.cern.ch/t/error-reference-to-medium-is-ambiguous/64272 "2025-10-02T09:20:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [October 2, 2025, 9:20am UTC](https://root-forum.cern.ch/t/error-reference-to-medium-is-ambiguous/64272/1 "2025-10-02T09:20:40Z")

</div>

Dear experts

I tried to rebuild my program which has succeeded many times, but after rebuild Garfield++ I got an error:

```auto
/group/had/muon/ssun/crt_simulation/time_resolution/diffusion_boundary/src/xt_simulation.cxx:112:9: error: reference to ‘Medium’ is ambiguous
  112 | Medium* m_dummy;
      | ^ ~~~~~
In file included from /group/had/muon/ICEDUST_externals/ICEDUST_externals_install/garfield_eca50bbce477905456dbe838aa19b08bb3880c27/include/Garfield/Medium.hh:19,
                 from /group/had/muon/ICEDUST_externals/ICEDUST_externals_install/garfield_eca50bbce477905456dbe838aa19b08bb3880c27/include/Garfield/MediumGas.hh:16,
                 from /group/had/muon/ICEDUST_externals/ICEDUST_externals_install/garfield_eca50bbce477905456dbe838aa19b08bb3880c27/include/Garfield/MediumMagboltz.hh:13,
                 from /group/had/muon/ssun/crt_simulation/time_resolution/diffusion_boundary/src/xt_simulation.hxx:14,
                 from /group/had/muon/ssun/crt_simulation/time_resolution/diffusion_boundary/src/xt_simulation.cxx:1:
/group/had/muon/ICEDUST_externals/ICEDUST_externals_install/garfield_eca50bbce477905456dbe838aa19b08bb3880c27/include/Garfield/Medium.hh:34:7: note: candidates are: ‘class Garfield::Medium’
   34 | class GARFIELD_CLASS_NAME(Medium) {
      | ^ ~~~~~~~~~~~~~~~~~~
In file included from /group/had/muon/ssun/crt_simulation/time_resolution/diffusion_boundary/src/xt_simulation.hxx:18,
                 from /group/had/muon/ssun/crt_simulation/time_resolution/diffusion_boundary/src/xt_simulation.cxx:1:
/group/had/muon/ICEDUST_externals/ICEDUST_externals_install/garfield_eca50bbce477905456dbe838aa19b08bb3880c27/include/Garfield/ComponentAnalyticField.hh:13:7: note: ‘class Medium’
   13 | class Medium;
      | ^ ~~~~~

```

I never get such error before. (I used the same version of Garfield++, but the system environment was different, and after environment changed I already rebuilt Garfield++), what should I do?

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [October 3, 2025, 9:07am UTC](https://root-forum.cern.ch/t/error-reference-to-medium-is-ambiguous/64272/2 "2025-10-03T09:07:46Z")

</div>

Hi,  
hmm, I don’t think I’ve seen this error before. Can you clarify what you mean by “the system environment was different, and after environment changed I already rebuilt Garfield++”? Which environment are you using?

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [October 14, 2025, 5:14am UTC](https://root-forum.cern.ch/t/error-reference-to-medium-is-ambiguous/64272/3 "2025-10-14T05:14:37Z")

</div>

I built Garfield++ once before, and that time the system was CentOS 7 and the gcc version was 9, after that, the server was changed and the system was upgraded to **AlmaLinux 9.6**. And then I rebuilt the Garfield++ with the new GCC version 11.5.0-5, then when I try to build my own simulation code this error message occurred.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [October 15, 2025, 7:42am UTC](https://root-forum.cern.ch/t/error-reference-to-medium-is-ambiguous/64272/4 "2025-10-15T07:42:40Z")

</div>

Hi,  
do you get the same error when you build one of the applications in the `Examples` folder?

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [October 15, 2025, 8:24am UTC](https://root-forum.cern.ch/t/error-reference-to-medium-is-ambiguous/64272/5 "2025-10-15T08:24:17Z")

</div>

> [@Crisps](#):
>
> `eca50bbce477905456dbe838aa19b08bb3880c27`

In this commit, I found that in `ComponentAnalyticField.hh` the `class Medium` was declared outside of `namespace Garfield`, in the newest commit it was moved inside the namespace. I changed the source code of Garfield and the error message disappeared.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [October 29, 2025, 8:24am UTC](https://root-forum.cern.ch/t/error-reference-to-medium-is-ambiguous/64272/6 "2025-10-29T08:24:50Z")

</div>

Closed on October 29, 2025, 8:24am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
