Skip to content

Using in conjunction with Qt #120

@EosPengwern

Description

@EosPengwern

If I #include a Qt header (specifically, the one I tried was <QFileDialog>) before including ryml.hpp, I get a compilation error:

(test.cpp - an otherwise empty file):

#include <QFileDialog>
#include <ryml.hpp>

gives me on Linux (Qt 5.15.2 with gcc 8.1):

In file included from rapidyaml/src/./c4/yml/yml.hpp:6,
                 from rapidyaml/src/ryml.hpp:4,
                 from _TestPropertiesWidget.cpp:19:
rapidyaml/src/./c4/yml/./emit.hpp:63:27: error: expected ‘)’ before ‘type’
     substr emit(EmitType_e type, Tree const& t, size_t id, bool error_on_excess);
                ~          ^~~~~
                           )
rapidyaml/src/./c4/yml/./emit.hpp:65:27: error: expected ‘)’ before ‘type’
     substr emit(EmitType_e type, Tree const& t, bool error_on_excess=true) { return emit(type, t, t.root_id(), error_on_excess); }
                ~          ^~~~~
                           )
In file included from rapidyaml/src/./c4/yml/yml.hpp:6,
                 from rapidyaml/src/ryml.hpp:4,
                 from _TestPropertiesWidget.cpp:19:
rapidyaml/src/./c4/yml/./emit.hpp:67:27: error: expected ‘)’ before ‘type’
     substr emit(EmitType_e type, NodeRef const& n, bool error_on_excess=true) { return emit(type, *n.tree(), n.id(), error_on_excess); }
                ~          ^~~~~
                           )
rapidyaml/src/./c4/yml/./emit.hpp:109:24: error: expected ‘)’ before ‘const’
 inline size_t emit(Tree const& t, size_t id, FILE *f)
                   ~    ^~~~~~
                        )
rapidyaml/src/./c4/yml/./emit.hpp: In function ‘size_t c4::yml::emit_json(const c4::yml::Tree&, size_t, FILE*)’:
rapidyaml/src/./c4/yml/./emit.hpp:120:25: error: expected unqualified-id before ‘(’ token
     size_t len = em.emit(JSON, t, id, /*error_on_excess*/true).len;
                         ^
rapidyaml/src/./c4/yml/./emit.hpp: At global scope:
rapidyaml/src/./c4/yml/./emit.hpp:127:24: error: expected ‘)’ before ‘const’
 inline size_t emit(Tree const& t, FILE *f=nullptr)
                   ~    ^~~~~~
                        )
rapidyaml/src/./c4/yml/./emit.hpp:142:27: error: expected ‘)’ before ‘const’
 inline size_t emit(NodeRef const& r, FILE *f=nullptr)
                   ~       ^~~~~~
                           )
rapidyaml/src/./c4/yml/./emit.hpp: In function ‘OStream& c4::yml::operator<<(OStream&, const c4::yml::Tree&)’:
rapidyaml/src/./c4/yml/./emit.hpp:162:12: error: expected unqualified-id before ‘(’ token
     em.emit(YAML, t.rootref());
            ^
rapidyaml/src/./c4/yml/./emit.hpp: In function ‘OStream& c4::yml::operator<<(OStream&, const c4::yml::NodeRef&)’:
rapidyaml/src/./c4/yml/./emit.hpp:172:12: error: expected unqualified-id before ‘(’ token
     em.emit(YAML, n);
            ^
rapidyaml/src/./c4/yml/./emit.hpp: In function ‘OStream& c4::yml::operator<<(OStream&, const c4::yml::as_json&)’:
rapidyaml/src/./c4/yml/./emit.hpp:181:12: error: expected unqualified-id before ‘(’ token
     em.emit(JSON, *js.tree, js.node);
            ^
rapidyaml/src/./c4/yml/./emit.hpp: At global scope:
rapidyaml/src/./c4/yml/./emit.hpp:191:24: error: expected ‘)’ before ‘const’
 inline substr emit(Tree const& t, size_t id, substr buf, bool error_on_excess=true)
                   ~    ^~~~~~
                        )
rapidyaml/src/./c4/yml/./emit.hpp: In function ‘c4::substr c4::yml::emit_json(const c4::yml::Tree&, size_t, c4::substr, bool)’:
rapidyaml/src/./c4/yml/./emit.hpp:203:28: error: expected unqualified-id before ‘(’ token
     substr result = em.emit(JSON, t, id, error_on_excess);
                            ^
rapidyaml/src/./c4/yml/./emit.hpp: At global scope:
rapidyaml/src/./c4/yml/./emit.hpp:210:24: error: expected ‘)’ before ‘const’
 inline substr emit(Tree const& t, substr buf, bool error_on_excess=true)
                   ~    ^~~~~~
                        )
rapidyaml/src/./c4/yml/./emit.hpp:226:27: error: expected ‘)’ before ‘const’
 inline substr emit(NodeRef const& r, substr buf, bool error_on_excess=true)
                   ~       ^~~~~~
                           )
In file included from rapidyaml/src/./c4/yml/./emit.hpp:363,
                 from rapidyaml/src/./c4/yml/yml.hpp:6,
                 from rapidyaml/src/ryml.hpp:4,
                 from _TestPropertiesWidget.cpp:19:
rapidyaml/src/./c4/yml/././emit.def.hpp:13:29: error: expected unqualified-id before ‘(’ token
 substr Emitter<Writer>::emit(EmitType_e type, Tree const& t, size_t id, bool error_on_excess)
                             ^

and on Windows (with the same version of Qt and VS2019):

emit.hpp(63,28): error C2146: syntax error: missing ')' before identifier 'type'
emit.hpp(100): message : see reference to class template instantiation 'c4::yml::Emitter<Writer>' being compiled
emit.hpp(63,1): error C3646: 'type': unknown override specifier
emit.hpp(63,39): error C2143: syntax error: missing ';' before 'const'
emit.hpp(63,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
emit.hpp(63,1): error C3646: 'id': unknown override specifier
emit.hpp(63,60): error C2062: type 'bool' unexpected
emit.hpp(65,28): error C2146: syntax error: missing ')' before identifier 'type'
emit.hpp(65,1): error C3646: 'type': unknown override specifier
emit.hpp(65,17): error C2086: 'c4::substr c4::yml::Emitter<Writer>::EmitType_e': redefinition
emit.hpp(63): message : see declaration of 'c4::yml::Emitter<Writer>::EmitType_e'
emit.hpp(65,39): error C2143: syntax error: missing ';' before 'const'
emit.hpp(65,34): error C2086: 'c4::substr c4::yml::Emitter<Writer>::Tree': redefinition
emit.hpp(63): message : see declaration of 'c4::yml::Emitter<Writer>::Tree'
emit.hpp(65,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
emit.hpp(65,46): error C2086: 'const int &c4::yml::Emitter<Writer>::t': redefinition
emit.hpp(63): message : see declaration of 'c4::yml::Emitter<Writer>::t'

...and many more in a similar vein. If I simply swap around the order of the two includes, putting ryml.hpp first, then everything works fine, on both platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions