Error: reference to ‘Medium’ is ambiguous

Dear experts

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

/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?

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?

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.

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

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.