Re: Warning on assigning a function-returning-a-pointer-to-arrays



spibou@xxxxxxxxx writes:
Keith Thompson wrote:
% cdecl
Type `help' or `?' for help
cdecl> explain int (*pfunc(void))[5]
declare pfunc as function (void) returning pointer to array 5 of int

In fact, I used cdecl myself to figure out how to declare a function
returning an array of int, the reverse of the above:

cdecl> declare p as function (void) returning pointer to array 5 of int
int (*p(void ))[5]

The reverse of what "above" ?

The cdecl "declare" command is the reverse (or inverse, if you prefer)
of the "explain" command.

And what do you mean "function
returning an array..." ? Functions in C don't return arrays.

You're right, of course; I meant "function returning a pointer to an
array", as I wrote in the cdecl "declare" command.

I actually thought I had found a bug in cdecl because it seemed just
too ugly to believe, but when I fed it to my compiler (with high
warning levels), it didn't complain.

I don't find it ugly at all.

Ok.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: NotSupportedException TomTomSDK
    ... The easiest way to marshal this data is as a byte array. ... use the System.Text.Encoding.Unicode.GetString to extract the inline string. ... BitConverter will allow you to get the int members out of the byte ... > Any ideas how to declare the TCHAR? ...
    (microsoft.public.pocketpc.developer)
  • Re: Using ternary and summing array
    ... So this declares my array as a global value. ... int a, ... With this skeleton shouldn't I declare int a,? ... initialized with a copy of the pointer value passed to three_five_sum ...
    (comp.lang.c)
  • Re: static array initialization in a class
    ... you declare a pointer and use it as an "array". ... For starters, you don't initialise arr. ... Even if those blocks were totally empty before you declared the int*, ...
    (comp.lang.cpp)
  • Cursor operations
    ... DECLARE @array TABLE (nameID INT NOT NULL, ... DECLARE arrayCursor CURSOR SCROLL FOR SELECT nameID, ... DECLARE @index INT, @count INT, @offset INT ...
    (microsoft.public.sqlserver.programming)
  • Re: Warning on assigning a function-returning-a-pointer-to-arrays
    ... declare pfunc as function returning pointer to array 5 of int ... what cdecl does: http://ieng9.ucsd.edu/~cs30x/rt_lt.rule.html ... cdecl> declare p as function returning pointer to array 5 of int ...
    (comp.lang.c)