Make empty array in struct compatible with C99
authorHans Ulrich Niedermann <hun@n-dimensional.de>
Sun, 25 Jan 2009 17:21:59 +0000 (18:21 +0100)
committerDaniel Drake <dsd@gentoo.org>
Sun, 1 Feb 2009 22:30:21 +0000 (19:30 -0300)
If the compiler is known to be running in C99 mode,
use "flexible array members" ("foo[]").

If the compiler is running in any other mode, continue
using the non-standard but widely common "foo[0]" syntax.

libusb/libusb.h

index cc9bd3b..fab053e 100644 (file)
@@ -747,7 +747,13 @@ struct libusb_transfer {
        int num_iso_packets;
 
        /** Isochronous packet descriptors, for isochronous transfers only. */
-       struct libusb_iso_packet_descriptor iso_packet_desc[0];
+       struct libusb_iso_packet_descriptor iso_packet_desc
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+       [] /* valid C99 code */
+#else
+       [0] /* non-standard, but usually working code */
+#endif
+       ;
 };
 
 int libusb_init(libusb_context **ctx);