本文介绍了从带有扩展的C到标准C的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 有几个编译器接受C语言的各种 扩展并生成本机 代码。但我想知道是否有任何提供 选项从C转换为一些扩展 到标准C. 解决方案 恐怕不行。他们扩展C的原因主要是标准C 不能做他们想要的事情。标准C的目标是便携性 而扩展C旨在优化低级操作或 某些架构。 也许很少有扩展可以译文,但大部分都没有。 恐怕不行。他们扩展C的原因主要是标准C 不能做他们想要的事情。标准C的目标是便携性 而扩展C旨在优化低级操作或 某些架构。 也许很少有扩展可以被翻译,但绝大多数没有。 你能给我一个扩展的例子吗? 无法翻译成(高效)标准C? 恐怕不行。他们扩展C的原因主要是标准C 不能做他们想要的事情。标准C的目标是便携性 而扩展C旨在优化低级操作或 某些架构。 也许很少有扩展可以被翻译,但绝大多数没有。 你能给我一个扩展的例子吗? 无法翻译成(高效)标准C? 当然。以下代码来自Linux内核,用 GCC扩展编写: #define typecheck(type,x)\ ({type __dummy; \ typeof(x)__dummy2; \ (void)(& __ dummy ==& __ dummy2); \ 1; \ }) 很难将其翻译成标准C. 当然,GCC的另一个明显的扩展是无法翻译的内联 asm。 There are several compilers which accept variousextensions to the C language and produce nativecode. But I wonder if there are any which offer theoption to translate from C with some extensionsto standard C. 解决方案 I am afraid not. The reason why they extend C is mainly that standard Ccan''t do the things that they want. Standard C is aimed at portabilitywhile extended C is aimed at optimizing for low level operations or forcertain architecture.Maybe few extensions can be translated, but most not. I am afraid not. The reason why they extend C is mainly that standard Ccan''t do the things that they want. Standard C is aimed at portabilitywhile extended C is aimed at optimizing for low level operations or forcertain architecture.Maybe few extensions can be translated, but most not.Can you give me an example of an extension whichcannot be translated into (efficient) standard C ? I am afraid not. The reason why they extend C is mainly that standard C can''t do the things that they want. Standard C is aimed at portability while extended C is aimed at optimizing for low level operations or for certain architecture. Maybe few extensions can be translated, but most not. Can you give me an example of an extension whichcannot be translated into (efficient) standard C ?Of course. The following code is from Linux kernel and is written withGCC 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 inlineasm, of course. 这篇关于从带有扩展的C到标准C的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 21:44