有没有办法将 C11 编译成 C89? [英] Is there a way of compiling C11 to C89?

查看:26
本文介绍了有没有办法将 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,定义明确在订购之前排序,未命名的 structunion 成员......这些在旧版本中没有对应部分,并且真的很难模仿.

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天全站免登陆