编译器独立代码 [英] Compiler independent code

查看:88
本文介绍了编译器独立代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在面试中被问到编码的基本问题



Qus:你怎么能编写一个不依赖于编译器的代码,即你必须编写一个你不知道客户端会在Windows环境或Linux环境中生成exe的代码。你怎么能这样做?



任何人都有线索...



谢谢

Hi,

I am asked an basic question of coding in an interview

Qus: How can you write a code which is not compiler dependent i.e You have to write a code which you don''t know client will generate exe for in Windows environment or in Linux environment. How can you do that?

Any one have a clue...

Thanks

推荐答案

大多数代码依赖于编译器,c和c#例如需要他们自己的编译器。



但问题是主要适用于cxx(c,c ++)语言,它们可以有多种不同的编译器(gcc,ms等),使代码编译的唯一真正方法是使用基础而不使用编译器特定或平台特殊扩展,例如在ANSI C中编写。
Most code is compiler dependent, c and c# for example require their own compilers.

However the question is mostly valid for cxx (c, c++) languages which can have a multitude of different compilers (gcc, ms, etc.), the only real way to get your code to compile is to go with the base and not use compiler specific or platform specific extensions like writing in ANSI C for example.


这篇关于编译器独立代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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