"Cong Wang" <xi************ @gmail.comwrite s:
Spiros Bousbouras wrote:
[...]
>Can you give me an example of an extension which
cannot be translated into (efficient) standard C ?
Of course. The following code is from Linux kernel and is written with
GCC extensions:
#define typecheck(type, x) \
({ type __dummy; \
typeof(x) __dummy2; \
(void)(&__dummy == &__dummy2); \
1; \
})
It can hardly be translated into standard C.
And another obvious extension of GCC that can't be translated is inline
asm, of course.
That specific construct can't be expressed in standard C, but any
program that uses it can be translated into an equivalent standard C
program. The extended-C to C translator would just have to replace
"typeof(x)" with the actual type of x.
There's precedent for this kind of thing; see cfront.
And another obvious extension of GCC that can't be translated is inline
asm, of course.
That's a better example. (I suppose a translator could emit standard
C code for a CPU emulator, but that's probably cheating.)
--
Keith Thompson (The_Other_Keit h)
ks***@mib.org <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.