Page MenuHomePhabricator

ecore: Fix compilation for GCC 4
ClosedPublic

Authored by lauromoura on Nov 21 2017, 2:53 PM.

Details

Summary

GCC4 support compound literals for static initializers only in C89. This
commit reverts to the previous behavior when using this version.

Currently we are using it to build on Windows.

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
lauromoura created this revision.Nov 21 2017, 2:53 PM
lauromoura added projects: Windows, efl.
jpeg requested changes to this revision.Nov 21 2017, 11:40 PM

This line should be changed, instead, I think:

#define EINA_VALUE_EMPTY ((Eina_Value){ NULL, { { 0, 0, 0, 0, 0, 0, 0, 0 } } })
This revision now requires changes to proceed.Nov 21 2017, 11:40 PM

maybe

#if (defined GNUC) && (GNUC <= 4)

to have no duplication of code ?

In D5518#94539, @jpeg wrote:

This line should be changed, instead, I think:

#define EINA_VALUE_EMPTY ((Eina_Value){ NULL, { { 0, 0, 0, 0, 0, 0, 0, 0 } } })

I thought about this but the problem is not with VALUE_EMPTY itself, but its usage in the declaration of a static. Other places it works normally.

I would expect that { 0 } work ok everywhere else to ? I do prefer to have it fixed on the declaration of EINA_VALUE_EMPTY as it will limit the likelyness of future breakage here.

jpeg added a comment.Nov 23 2017, 6:32 PM
In D5518#94662, @cedric wrote:

I would expect that { 0 } work ok everywhere else to ? I do prefer to have it fixed on the declaration of EINA_VALUE_EMPTY as it will limit the likelyness of future breakage here.

If only. This is basically what I think should be standard C. But when I do:

#define EINA_VALUE_EMPTY {0}

I get this:

/home/jpeg/e/core/efl/src/lib/eina/eina_promise.c:1142:33: error: expected expression
   if (ctx->dispatching) return EINA_VALUE_EMPTY;
                                ^
/home/jpeg/e/core/efl/src/lib/eina/eina_value.h:317:26: note: expanded from macro 'EINA_VALUE_EMPTY'
#define EINA_VALUE_EMPTY {0}
                         ^
/home/jpeg/e/core/efl/src/lib/eina/eina_promise.c:1187:23: error: expected expression
        ctx->values = EINA_VALUE_EMPTY; /* flushed in _eina_promise_clean_dispatch() */

This is with clang 5. It's an error. {0} works only for initialization while the full form works for assignment in GCC 5+/Clang.

This revision was automatically updated to reflect the committed changes.