Doing without GCC's statement-blocks-as-expressions extension

Nicholas Sherlock n.sherlock@gmail.com
Wed Apr 29 04:55:00 GMT 2009


Ian Lance Taylor wrote:
> Since you are generating C code, you control the horizontal and the
> vertical.  Count the number of virtual calls you have, and emit 
>     struct object_header *__my_private_temp_1;
>     struct object_header *__my_private_temp_2;
>     ...
> at the start of the C function.   Then for each virtual call do
>     (__my_private_temp_N = objectexpression,
>      ((int(*)(struct object_header *, int))
>       (temp->vmt[VMTINDEX_MyObject_square))(__my_private_temp_N, 5)))
> replacing N with the index of the call.

Ah, of course! That will make the code a lot nicer than what I was thinking.

Thanks!

Nicholas Sherlock



More information about the Gcc-help mailing list