Search code examples
c++macros

'clas_name': is not a class or namespace name when trying to build macro in c++


i have this macro :

    #define CONCAT_CLSS(clss, mtd) &clss::mtd
    #define EXPORT_X(getter, setter, class_name, arg_name,set,get)                    \
        godot::ClassDB::bind_method(godot::D_METHOD(getter), CONCAT_CLSS(clas_name,get)); \
        godot::ClassDB::bind_method(godot::D_METHOD(setter, arg_name),  CONCAT_CLSS(clas_name,set)); \
        ADD_PROPERTY(godot::PropertyInfo(godot::Variant::FLOAT, arg_name), setter, getter);


//when calling it from : 
void Plaine::_bind_methods()
    {
         
        EXPORT_X("get_gravity","set_gravity", Plaine, "gravity", set_gravity, get_gravity)
    }
    

this defined in different class :

#define ADD_PROPERTY(m_property, m_setter, m_getter) godot::ClassDB::add_property(get_class_static(), m_property, m_setter, m_getter)

I don't understand why it complains about the class name here , also how can i make this macro shorter ?

Im getting this error :

plane.cpp
src\plane.cpp(33): error C2653: 'clas_name': is not a class or namespace name

now the class do exist as i call from it


Solution

  • Typo: clas_name -> class_name

    For example:

    + CONCAT_CLSS(class_name,get)
    - CONCAT_CLSS(clas_name,get)