Eclipse Indigo C ++项目设置 [英] Eclipse Indigo C++ project settings

查看:214
本文介绍了Eclipse Indigo C ++项目设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu中使用编译器 g ++ 4.6 创建了一个C ++共享库项目。

一些依赖库期望一些关于编译器的预处理器命令操作系统正确编译,如

I created a C++ shared library project in Ubuntu with compiler g++ 4.6.
Some of the dependency libraries expects some preprocessor commands about compiler and operating system to properly compile, like

#elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__)

然而, Eclipse 不会自动定义至少我使用的版本),Eclipse中有一个设置或选项,为我做这个吗?

However Eclipse doesn't define them automatically (at least the version I'm using), is there a setting or option in Eclipse which does this for me ?

推荐答案

你可以在项目属性中设置预处理器定义:。

You can set preprocessor defines in the project properties: .

然而,在你的情况下,我不会使用这些,因为它们不应该是项目特定的(由于它们是编译器特定的)。我其实觉得你在找这些。我不知道llvm / clang(有一些,但我现在不记得他们),但是对于GCC,你应该使用宏 __ GNUC __ 由编译器本身定义,无需担心。领先的下划线告诉你,它们不是标准的一部分,在使用另一个编译器(例如MSVC)时不一定定义。

However, in your case, I wouldn't use these, as they shouldn't be project specific (due to them being compiler specific). I actually think you're looking for these. I'm not sure for llvm/clang (there are ones, but I don't remember them right now), but for GCC you should use the macro __GNUC__ which will be defined by the compiler itself, without you having to worry about it. The leading underscores tell you, that they aren't part of the standard and not necessarily defined when using another compiler (e.g. MSVC).

对于 vsprintf_s 的跨平台使用:

// this will be set on Visual Studio only, so this code is added for all other compilers
#ifndef _MSC_VER
#define vsprintf_s(b,l,f,v) vsprintf(b,f,v);
#endif

但一般来说,尝试使用所有平台上可用的功能(在这种情况下,在这种情况下,请使用 vsnprintf()

But in general, try to use functions that are available on all platforms (for this example, in this case use vsnprintf() instead).

这篇关于Eclipse Indigo C ++项目设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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