C language > Tips & tricks

Difficult declarations

(1/2) > >>

JohnF:
An interesting code snippet that tells you what a declaration is. For example, many will find the following difficult;


--- Code: ---char *(*c[10])(int **p);
--- End code ---


The program output for the above is

"c is array 0..9 of pointer to function returning pointer to char"

I think the code was by Peter van der Linden

John

jack:
Thanks JohnF, I have been looking for a utility that would de-mystify declarations, especially declarations with structures.
Now if you would extend this utility to graphically display variable declarations and structures as a tree-view I would pay for it. :)

JohnF:

--- Quote from: "jack" ---Thanks JohnF, I have been looking for a utility that would de-mystify declarations, especially declarations with structures.
Now if you would extend this utility to graphically display variable declarations and structures as a tree-view I would pay for it. :)
--- End quote ---


Can you give an example?

John

Mikehg:
Hi John,

It seems this could be a lot more useful if the data type didn't need to be known.  i.e. it might be written as char* or LPSTR. and of course UDT's.

Thanks,
Mike H.

JohnF:
I doubt it would take much to add the extra code to deal with Windows types.

EDIT: Or you could try to do it your way.

John

Navigation

[0] Message Index

[#] Next page

Go to full version