有没有一种将C11编译为C89的方法? [英] Is there a way of compiling C11 to C89?

查看:70
本文介绍了有没有一种将C11编译为C89的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个(嵌入式)目标只有一个C89编译器。

One of my (embedded) targets only has a C89 compiler.

我正在从事针对多个设备的(业余)项目。

I am working on a (hobby) project which targets multiple devices.

有没有一种将C11代码库编译(转换为C89)的方法?

Is there a way of compiling (transpiling?) a C11 code base into C89?

(否则,我将不得不像从字面上看是1989年。)

(Otherwise I will have to code like it's 1989, literally.)

推荐答案

不,我不认为所有C11都有可能。 C11具有C89或C99根本不存在的功能: _Generic _Atomic _Thread _Alignof ,在订购前已明确定义顺序,未命名 struct union 成员...这些成员在较旧的版本中没有对应部分,模仿真的很难。

No I don't think that it is possible for all of C11. C11 has features that simply not exist in C89 or C99: _Generic, _Atomic, _Thread, _Alignof, well defined sequenced before ordering, unnamed struct and union members ... These don't have counter parts in the older versions and would be really difficult to emulate.

对于任何这些功能,您都必须依赖目标编译器的扩展,因此对于一个给定编译器而言,某些功能可能是可能的。但是编写这样一个以普通C89作为通用目标的工具将是一场噩梦。您最好直接实现C11编译器。

For any of these features you would have to rely on extensions of your target compiler, so probably possible for some of the features for one given compiler. But it would be a nightmare to write such a tools that would have plain C89 as a generic target. You'd better implement a C11 compiler directly.

这篇关于有没有一种将C11编译为C89的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆