c + +前端仅有的编译器(转换成C ++到C) [英] C++ frontend only compiler (convert C++ to C)

查看:234
本文介绍了c + +前端仅有的编译器(转换成C ++到C)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在管理的多个平台上从单一的源代码树的(Win32,Linux和Verifone的CC端子,MBED甚至任天堂GBA / DS)中运行一些C ++ code。不过,我需要(仅C)建立在一个嵌入式平台,其中有没有C ++编译器为对象的应用程序。我remmber,很多早期的C ++编译器只是前端stitting现有的C编译器(铁琴如使用MSC)。是否有任何使用这种前端C ++编译器今天将生成C code。

I'm currently managing some C++ code that runs on multiple platforms from a single source tree (Win32, Linux, Verifone CC terminals, MBED and even the Nintendo GBA/DS). However I need to build an app targetted at an embedded platform for which there is no C++ compiler (C only). I remmber that many of the early C++ compilers were only front-ends stitting on existing C compilers (Glockenspiel for example used MSC). Are there any such 'frontend' C++ compilers in use today that will generate C code.

                      Tools            Platform
                      -----------      ------------

                ______Visual C++ _____ WIN32
               /
              /_______MBED (ARM)_______MBED (ARM dev board).
             /
            /_________GCC (x86)________Linux
           /
Source____/___________GCC (ARM)________GBA/DS
          \
           \__________SDA______________Verifone Verix CC Terminals
            \
             \________ARM SDT__________Verifine VerixV CC terminals
              \
               \______????_____________Renases M8/16/32.
                \
                 \____????_____________Z8 family.

最后两个平台,我有很好的C编译器,但没有C ++。

The last two platforms I have good C compilers for but no C++.

如你所见,我支持大量不同的平台和我共享一个庞大的身躯库code(以及一些应用code)。

As you can see I'm supporting a large variety of platforms and I share a large body of library code (and some app code).

推荐答案

如果您使用 LLVM ,的 LLVM-G ++ 会编译C ++ code到LLVM位code和 有限责任公司 具有位code转换为C的后端

If you use LLVM, llvm-g++ will compile your C++ code to LLVM bitcode, and llc has a backend which converts bitcode to C.

您可以写这样的命令:

llvm-g++ -emit-llvm -c foo.cpp -o foo.o
llc -march=c <foo.o >foo.c

这篇关于c + +前端仅有的编译器(转换成C ++到C)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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