gnu.gcc.help
[Top] [All Lists]

can users extract the type of an expression?

Subject: can users extract the type of an expression?
From: Mark W Maimone
Date: 18 Jul 2006 23:25:37 GMT
Newsgroups: gnu.gcc.help
I'd like to find the type of an arbitrary expression.  Ideally, this
would be in the form of a string, e.g., this doesn't actually work but
something like it would be nice:

        #define TYPE_STRING(e) Stringify(typeof e)

But even a compile-time message would be acceptable.  Basically I'd
like to walk thru the (fixed number of) actual parameters of a
function, displaying the type of each actual parameter, before they're
cast into the formal parameter types associated with the function
prototype.

E.g., from this:

        char *fmt = "%d";
        enum { one, two, three } arg1;

        /* ... */

        my_printf (fmt, arg1 )

I'd like to automatically infer that fmt is a char*, and arg1 is an
enum type, without having to search back in the source for the
appropriate declaration.

Any way to force the compiler to tell me this?
-- 
------------------------------------------------------------------------------
Mark Maimone                              phone: +1 (818) 354 - 0592
NASA Jet Propulsion Lab, Caltech          fax:   +1 (818) 393 - 2346
http://robotics.jpl.nasa.gov/people/mwm   email: mark.maimone@xxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>
  • can users extract the type of an expression?, Mark W Maimone <=
Privacy Policy