Commit d5cd8fbf authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Markus Armbruster
Browse files

qlit: Change compound literals to initializers

The QLIT_QFOO() macros expand into compound literals.  Sadly, gcc
doesn't recognizes these as constant expressions (clang does), which
makes the macros useless for initializing objects with static storage
duration.

There is a gcc bug about it:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71713



Change the macros to expand into initializers.

Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170825105913.4060-5-marcandre.lureau@redhat.com>
[Commit message improved]
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent 082696e7
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -36,13 +36,13 @@ struct QLitDictEntry {
};

#define QLIT_QNUM(val) \
    (QLitObject){.type = QTYPE_QNUM, .value.qnum = (val)}
    { .type = QTYPE_QNUM, .value.qnum = (val) }
#define QLIT_QSTR(val) \
    (QLitObject){.type = QTYPE_QSTRING, .value.qstr = (val)}
    { .type = QTYPE_QSTRING, .value.qstr = (val) }
#define QLIT_QDICT(val) \
    (QLitObject){.type = QTYPE_QDICT, .value.qdict = (val)}
    { .type = QTYPE_QDICT, .value.qdict = (val) }
#define QLIT_QLIST(val) \
    (QLitObject){.type = QTYPE_QLIST, .value.qlist = (val)}
    { .type = QTYPE_QLIST, .value.qlist = (val) }

int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs);