Pelles C forum
C language => Tips & tricks => Topic started by: JohnF on September 22, 2005, 11:10:02 AM
-
An interesting code snippet that tells you what a declaration is. For example, many will find the following difficult;
char *(*c[10])(int **p);
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
-
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. :)
-
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. :)
Can you give an example?
John
-
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.
-
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
-
I've made a few changes to this project.
It will deal with a commandline arg, makes it easier for testing and development.
The types are now stored in an array so more types can be added easily as required.
char * sTypes[] = {"void",
"char",
"LPSTR",
"LPCSTR",
"signed",
"unsigned",
"short",
"WORD",
"int",
"INT",
"long",
"LONG",
"DWORD",
"float",
"double",
"struct",
"union",
"enum"}; // 18
#define NUMTYPES 18
John