GCC error when using code blocks for const unsigned long

Consider this code

class Reflect : public flemax::annotation::XAnnotation {
  public:
    Reflect(const unsigned long id, const std::string& home, const char type, const std::string& name = "me", const int value = 4, const bool valid = false, const signed char gender = 'M') : id_(id), home_(home), type_(type), name_(name), value_(value), valid_(valid), gender_(gender){} 
    ~Reflect() {}

    const unsigned long id() { return id_; }
    const std::string& home() { return home_; }
    const char type() { return type_; }
    const std::string& name() { return name_; }
    const int value() { return value_; }
    const bool valid() { return valid_; }
    const signed char gender() { return gender_; }

  private:
    const unsigned long id_;
    const std::string home_;
    const char type_;
    const std::string name_;
    const int value_;
    const bool valid_;
    const signed char gender_;

}; // class Reflect

it does not compile, and the compiler gives me this strange error.

||=== flemax_base, DebugAnnotator ===|
/programming/cpp-projects/flemax/flemax_base/base/xannottest.cc|21|error: expected ‘,’ or ‘...’ before ‘long’|
/programming/cpp-projects/flemax/flemax_base/base/xannottest.cc|24|error: expected ‘;’ before ‘long’|
/programming/cpp-projects/flemax/flemax_base/base/xannottest.cc|25|error: expected ‘;’ before ‘const’|
/programming/cpp-projects/flemax/flemax_base/base/xannottest.cc|33|error: expected ‘;’ before ‘long’|
/programming/cpp-projects/flemax/flemax_base/base/xannottest.cc||In constructor ‘flemax::test::Reflect::Reflect(int)’:|
/programming/cpp-projects/flemax/flemax_base/base/xannottest.cc|21|error: classflemax::test::Reflectdoes not have any field namedid_’|
/programming/cpp-projects/flemax/flemax_base/base/xannottest.cc|21|error: ‘id’ was not declared in this scope|
/programming/cpp-projects/flemax/flemax_base/base/xannottest.cc|21|error: argument of type ‘const int (flemax::test::Reflect::)()’ does not match ‘const int’|
/programming/cpp-projects/flemax/flemax_base/base/xannottest.cc|21|error: argument of type ‘const bool (flemax::test::Reflect::)()’ does not match ‘const bool’|
/programming/cpp-projects/flemax/flemax_base/base/xannottest.cc|21|error: argument of type ‘const signed char (flemax::test::Reflect::)()’ does not match ‘const signed char’|
||=== Build finished: 12 errors, 0 warnings ===|

when i delete the unsigned modifier everything works fine. I probably coded the last 24 hours, so I don’t understand what happened and I am amazed. I do not want to sleep until this code compiles as it is.

am using code blocks on ubuntu and gcc 4.4.3

Thank you men

+3
source share
2 answers

I would argue that you have #define unsigned WHATEVERsomewhere. Or maybe you are compiling with -Dunsigned=WHATEVER.

So, the compiler sees const WHATEVER long xeverywhere, and the type longdoes not make sense.

+3
source

, gcc 4.6.3. .

, , . , . , .

0

All Articles