[vlc-devel] Re: Compiling with visual studio 2005
Rémi Denis-Courmont
rem at videolan.org
Thu Dec 21 12:58:04 CET 2006
Hello,
Le jeudi 21 décembre 2006 11:56, Mortisandraco a écrit :
(...)
> For example, in libvlc there are a couple of times you used something
> like: void foo(int i)
> {
> char array[i];
> ...
>
> I need to look it up but I don't think that's possible in the c
> standard.
It looks like a perfectly standard variable-length array.
From ISO/IEC 9899:TC2 § 6.7.5.2 Array declarators, constraints:
"1 (...) the [ and ] may delimit an expression (...). If they delimit an
expression, the expression shall have an integer type. If the
expression is a constant expression, it shall have a value greater than
zero. (...)
4 (...) If the size is an integer constant expresssion and the element
type has a known constant size, the array type is not a variable-length
array type; otherwise the array type is a variable-length array type.
(...)"
> Currently I'm at the download limit of my provider so I
> can't download cygwin to check with gcc (--pedantic IIRC).
I don't know if -pedantic will work. I know from experience that
switching from -std=gnu99 to -std=c99 removes all the non-ISO APIs,
which understandably does not work with VLC. It's a pity considering we
do not necessarily want to include non-standard GNU constructs. On the
other hand, I think we use some non-standard "__attribute__" when
compiling under GCC, and I don't know what happens if using -pedantic
or -std=c** either.
> I changed the code to char* array = malloc(i * sizeof(char));
By the way, note that sizeof(char) == 1 per definition.
Best regards,
--
Rémi Denis-Courmont
http://www.remlab.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20061221/323df5ed/attachment.sig>
More information about the vlc-devel
mailing list