[ccan] dgraph, tlist, tcon: MSVC error due to array of flexible structs

David Gibson david at gibson.dropbear.id.au
Tue Aug 1 15:22:05 AEST 2017


On Thu, Sep 22, 2016 at 10:31:16PM -0600, Kevin Locke wrote:
1;4803;0c> Hi all,
> 
> Building dgraph using Microsoft Visual C++ produces the following
> error:
> 
> dgraph.h(25): error C2233: 'edge': arrays of objects containing
> zero-size arrays are illegal
> 
> The issue is that MSVC supports flexible array members, but does not
> support arrays of structs with flexible array members.  My
> understanding is that such support is not required by C99 or C11, but
> I don't know whether such support is common beyond Clang/GCC.
> 
> Is there any interest in supporting such compilers?  If so, I can see
> a few potential fixes:
> 
> 1. Change TCON to use flexible array members only when the compiler
> supports arrays of structs with flexible array members.  This is an
> easy fix, but wastes space for every TCON/TLIST usage on such
> compilers.
> 
> 2. Have TCON (and TLIST) provide an alternative macro which uses
> flexible array members only when supported in arrays, and use that in
> dgraph.  It would increase the API and duplicate a bit of code, but
> would only waste space when TCON/TLIST are placed in arrays.
> 
> 2. Replace the 2-element edge array in struct dgraph_node with
> separate fields edge_from and edge_to.  This complicates the logic a
> bit, since it is no longer symmetric with dgraph_edge.  It would also
> be an incompatible API change.
> 
> 3. Change TLIST to use TCON_WRAP?  I don't understand TLIST/TCON well
> enough to know if this is really an option.  Hopefully an expert can
> weigh in here.

I've now done this for tlist and several other modules, we should have
a much better chance of compiling on windows.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20170801/bc03363c/attachment.sig>


More information about the ccan mailing list