curv3d / curv

a language for making art using mathematics
Apache License 2.0
1.14k stars 73 forks source link

Build fails (clang): redefinition of 'ImGuiDataTypeInfo'; 'static_assertion___line__' declared as an array with a negative size; etc #80

Closed yurivict closed 5 years ago

yurivict commented 5 years ago

clang-6 prints these errors:

/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/libcurv/geom/viewer/scale_picker.cc:44:8: error: redefinition of 'ImGuiDataTypeInfo'
struct ImGuiDataTypeInfo
       ^
/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/extern/imgui/imgui_internal.h:543:8: note: previous definition is here
struct ImGuiDataTypeInfo
       ^
/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/libcurv/geom/viewer/scale_picker.cc:65:1: error: 'static_assertion___line__' declared as an array with a negative size
IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/extern/imgui/imgui_internal.h:136:82: note: expanded from macro 'IM_STATIC_ASSERT'
#define IM_STATIC_ASSERT(_COND)         typedef char static_assertion_##__line__[(_COND)?1:-1]
                                                                                 ^~~~~~~~~~~~
/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/libcurv/geom/viewer/scale_picker.cc:286:151: error: no member named 'ScalarAsInputTextId' in 'ImGuiContext'
    if (tab_focus_requested || (hovered && (g.IO.MouseClicked[0] || g.IO.MouseDoubleClicked[0])) || g.NavActivateId == id || (g.NavInputId == id && g.ScalarAsInputTextId != id))
                                                                                                                                                    ~ ^
/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/libcurv/geom/viewer/scale_picker.cc:295:15: error: no member named 'ScalarAsInputTextId' in 'ImGuiContext'
            g.ScalarAsInputTextId = 0;
            ~ ^
/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/libcurv/geom/viewer/scale_picker.cc:298:52: error: no member named 'ScalarAsInputTextId' in 'ImGuiContext'
    if (start_text_input || (g.ActiveId == id && g.ScalarAsInputTextId == id))
                                                 ~ ^
/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/libcurv/geom/viewer/scale_picker.cc:299:16: error: use of undeclared identifier 'InputScalarAsWidgetReplacement'
        return InputScalarAsWidgetReplacement(frame_bb, id, label, data_type, v, format);
               ^
/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/libcurv/geom/viewer/scale_picker.cc:314:45: error: call to 'DataTypeFormatString' is ambiguous
    const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, v, format);
                                            ^~~~~~~~~~~~~~~~~~~~
/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/extern/imgui/imgui_internal.h:1577:29: note: candidate function
    IMGUI_API int           DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* data_ptr, const char* format);
                            ^
/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/libcurv/geom/viewer/scale_picker.cc:93:1: note: candidate function
DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* data_ptr, const char* format)
^
7 errors generated.
doug-moen commented 5 years ago

I don't get this error when I build with clang-6.

The git project includes imgui as a submodule, and that submodule is locked to commit e0cab5664adf02c030f9cf2a05d2c334638a85f8. Curv will only compile with that specific version of imgui. This is because scale_picker.cc copies some of the internal implementation details of imgui. I created my own ImGui widget by copy, paste and modify of an existing ImGui widget.

In this error message:

/usr/ports/math/curv/work/curv-0.4-83-g49b28a58/extern/imgui/imgui_internal.h:543:8: note: previous definition is here struct ImGuiDataTypeInfo

there should not be a definition of ImGuiDataTypeInfo on line 543 of imgui_internal.h, which makes me wonder if you are deliberately using a different version of imgui than what is specified in the Curv git configuration. ImGuiDataTypeInfo is not declared in a header file, it is defined in imgui_widgets.cpp, which is why I was forced to copy the type definition in the first place.

yurivict commented 5 years ago

Thanks, the version was wrong.