[cfe-dev] static keyword @ Function declarators...

Jean-Daniel Dupas devlists at shadowlab.org
Wed Sep 12 05:15:21 PDT 2012

I don't have code that use it right here but for example you may want to write a function that read a 32 bytes fixed size header.

Whatever_t readHeader(char bytes[static 32]);

Le 12 sept. 2012 à 12:11, Umesh Kalappa <umesh.kalappa0 at gmail.com> a écrit :

> Hi Richard,
> Thank you for the reply and I'm looking at real/piratical cases or need that  requires the prototype like   int func(int array[static 100]).
> ~Umesh 
> On Wed, Sep 12, 2012 at 1:53 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Wed, Sep 12, 2012 at 12:16 AM, Umesh Kalappa <umesh.kalappa0 at gmail.com> wrote:
> Hi All ,
> Was going through the C99 standard @ http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf which states that the Function declarators as 
> direct-declarator ( parameter-type-list )
> parameter-list: parameter-declaration
>                       parameter-list , parameter-declaration
> parameter-declaration: declaration-specifiers declarator
>                               declaration-specifiers abstract-declarator
> direct-declarator [ static type-qualifier-listopt assignment-expression ]
> where The optional type qualifiers and the keyword static shall appear only in a declaration of a function parameter with an array type, and then only in the outermost
> array type derivation and then for each call to the function, the value of the corresponding actual argument shall provide access to the first element of an array with at least as many elements as specified by the size expression.
> for example : int func(array[static int i =100) ;
> I'm trying to get  the test case for the above function prototype ??? Please someone can shed some lights here ??
> I'm not sure what you're looking for, but there are a few errors in your example, which might be hindering you. Try:
>   int func(int array[static 100]);
> Clang has some test cases for this in test/Sema/static-array.c.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-- Jean-Daniel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120912/e839548d/attachment.html>

More information about the cfe-dev mailing list