compilation error "error: ‘Suffix’ is not a class or namespace" for LAMMPS (4 Feb 2020)

Dear Axel,
it seems there is a bug about the definition of variable “Suffix”, . The compilation error is shown as following:

…/angle.cpp: In constructor ‘LAMMPS_NS::Angle::Angle(LAMMPS_NS::LAMMPS*)’:
…/angle.cpp:35:17: error: ‘Suffix’ is not a class or namespace
suffix_flag = Suffix::NONE;

The reason is that “suffix_flag” is defined as integer type (int suffix_flag), but “Suffix” is a enum type.

To solve this problem, I add c++11 support (-std=c++11),and update suffix.h and pair_hybrid.cpp as following:

#######patch file#######
— suffix.h 2020-02-27 09:08:50.000000000 +0800
+++ suffix.h.new 2020-02-27 09:09:17.000000000 +0800
@@ -16,7 +16,7 @@

namespace LAMMPS_NS {

-enum Suffix {
+enum Suffix: int {
NONE = 0,
OPT = 1<<0,
GPU = 1<<1,
— pair_hybrid.cpp 2020-02-27 09:14:31.000000000 +0800
+++ pair_hybrid.cpp.new 2020-02-27 09:15:39.000000000 +0800
@@ -927,7 +927,7 @@

// have to cast to PairHybrid to work around C++ access restriction

  • if (((PairHybrid *)styles[m])->suffix_flag & (suffix::INTEL|suffix::GPU))
  • if (((PairHybrid *)styles[m])->suffix_flag & (Suffix::INTEL|Suffix::GPU))
    error->all(FLERR,"Pair_modify special is not compatible with "
    “suffix version of hybrid substyle”);

Yours,
Cun

Dear Axel,
it seems there is a bug about the definition of variable “Suffix”, . The compilation error is shown as following:

…/angle.cpp: In constructor ‘LAMMPS_NS::Angle::Angle(LAMMPS_NS::LAMMPS*)’:
…/angle.cpp:35:17: error: ‘Suffix’ is not a class or namespace
suffix_flag = Suffix::NONE;

The reason is that “suffix_flag” is defined as integer type (int suffix_flag), but “Suffix” is a enum type.

Thanks for reporting,

but that is not the problem and the code in that patch version compiles as is with C++11 enabled.
The more portable fix is to put the enumerator definition into a namespace Suffix instead of using the enumerator name as a scope designator.
this is already corrected in the 18 February LAMMPS version.

Your change to pair style hybrid is bogus. it was never suffix:: always Suffix::

Thanks,
Axel.