0

There is derived class BoundingBox3Base:

template <class PointClass>
class BoundingBox3Base : public BoundingBoxBase<PointClass>
{
public:
BoundingBox3Base(const std::vector<PointClass>& points)
    {
        // ...
        
        // ** Error happens at this line:
        // ** error C2059: syntax error: '('
        this->defined = (this->min(0) < this->max(0)) && (this->min(1) < this->max(1)) && (this->min(2) < this->max(2));
    }
};

Derived from a base class BoundingBoxBase:

template <class PointClass>
class BoundingBoxBase
{
public:
    PointClass min;
    PointClass max;
    bool defined;

    BoundingBoxBase(const std::vector<PointClass>& points) : min(PointClass::Zero()), max(PointClass::Zero())
    {
        if (points.empty()) {
            this->defined = false;
            
        } else {
            // ...
            
            this->defined = (this->min(0) < this->max(0)) && (this->min(1) < this->max(1));
        }
    }
};

I'm receiving this compile error at the marked** line:

error C2059: syntax error: '('

I cannot figure out what I'm missing! Can anybody help?

RESOLVED

The issue got resolved by suppressing the min and max definitions in Windef.h by defining NOMINMAX as suggested here.

Megidd
  • 7,089
  • 6
  • 65
  • 142
  • Can't [reproduce](https://godbolt.org/z/9bGT55). Please add the compiler, and language version. – cigien Oct 01 '20 at 15:38
  • @cigien MSVC 2017 (C++17) – Megidd Oct 01 '20 at 15:39
  • For me it compiled, *after* added a `;` after class declaration – Damien Oct 01 '20 at 15:39
  • @Damien Copy-paste mistake, added `;` – Megidd Oct 01 '20 at 15:41
  • You don't call the base class constructor; we do need to see more of your code so we can try to reproduce the error. As it is, we cannot answer this. Also, where do you instantiate the template? – Ken Y-N Oct 01 '20 at 15:42
  • I used gcc 7.4.0 – Damien Oct 01 '20 at 15:43
  • @Damien Thanks. For some reason, I'm receiving the error. Might be related to more of my code ... – Megidd Oct 01 '20 at 15:45
  • 2
    Please show the class definition for the *actual* type you use as the `PointClass` template parameter. Does it have a suitable `operator()` member defined? – G.M. Oct 01 '20 at 15:48
  • 2
    Given that others can't reproduce the syntax error, this is likely in the surrounding code. Try to create a minimal reproducible example. This also reeks of macros. examine your preprocessor output. – dhavenith Oct 01 '20 at 15:48
  • 1
    My crystal ball says that you have `#include` and that the infamous [`min`/`max` macros](https://stackoverflow.com/q/11544073/8586227) have you. – Davis Herring Oct 01 '20 at 23:15
  • @DavisHerring Thanks! I didn't check yet! Let me check when I'm back =) – Megidd Oct 02 '20 at 04:39
  • @DavisHerring I double-checked! You were absolutely right =) – Megidd Oct 02 '20 at 07:49

0 Answers0