conditional-compilation

How do I exclude a file from being built on OS X?

故事扮演 提交于 2019-12-01 21:33:39
问题 I have src/bin/linux-only.rs which does some things which work on Linux only (e.g. libc bindings which only exist on Linux). I want to exclude that file from being built on OS X. I started putting #[cfg(target_os = "linux")] on every block in linux-only.rs but that is cluttering up the source code beyond any reason. Is there a nicer way to do this? 回答1: Writing #![cfg(target_os = "linux")] (note the exclamation mark) at the top of the file will work for the whole file (as long as it contains

How do I exclude a file from being built on OS X?

我的未来我决定 提交于 2019-12-01 19:25:51
I have src/bin/linux-only.rs which does some things which work on Linux only (e.g. libc bindings which only exist on Linux). I want to exclude that file from being built on OS X. I started putting #[cfg(target_os = "linux")] on every block in linux-only.rs but that is cluttering up the source code beyond any reason. Is there a nicer way to do this? Writing #![cfg(target_os = "linux")] (note the exclamation mark) at the top of the file will work for the whole file (as long as it contains a single module), not just for the next block (item). Source: Rust reference . Edit : if you can move that

Using conditional compilation symbols in MVC views

北慕城南 提交于 2019-12-01 15:53:40
In "Properties" of my project I have the following: I want to check if TEST symbol exists, and only then, do some things. So I did what you see in the picture below and in the class it works. However this does not work in the views. The text in this block is gray even if TEST is defined! How can I cause it work if TEST is defined? The problem is related to the fact that views are only compiled when you run your application so the TEST symbol that you defined is no longer applied by the compiler because it has no knowledge of it. Assuming that you are using C# you need to configure the compiler

Can I define an environment variable and use it in conditional compilation?

被刻印的时光 ゝ 提交于 2019-12-01 14:55:43
问题 I know that I can do this in a *.h file: #ifdef _DEBUG #pragma comment(lib, "libtiffd.lib") #else #pragma comment(lib, "libtiff.lib") #endif But I want a way that I can do something such as this: #ifdef V2.4.6 #ifdef _DEBUG #pragma comment(lib, "opencv_calib3d246d.lib") #else #pragma comment(lib, "opencv_calib3d246.lib") #endif #else #ifdef _DEBUG #pragma comment(lib, "opencv_calib3d249d.lib") #else #pragma comment(lib, "opencv_calib3d249.lib") #endif #endif and V2.4.6 be an environment

C# conditional compilation if assembly exists

☆樱花仙子☆ 提交于 2019-12-01 10:44:48
I have a project with a reference that may or may not exist. I have code that uses that reference and I'd like to compile it only if the assembly exists. I'm thinking something along the lines of: #if ASSEMBLY_EXISTS AssemblyClass.DoSomething(); #endif I could put a #define at the top and comment/uncomment as needed, but I'd prefer if it could just somehow know if it's there without my manual intervention, which leads me to believe that #if won't work for this situation. Is there another way to conditionally compile based on whether an assembly exists? Maybe do it with a condition inside

C# conditional compilation if assembly exists

梦想的初衷 提交于 2019-12-01 08:35:29
问题 I have a project with a reference that may or may not exist. I have code that uses that reference and I'd like to compile it only if the assembly exists. I'm thinking something along the lines of: #if ASSEMBLY_EXISTS AssemblyClass.DoSomething(); #endif I could put a #define at the top and comment/uncomment as needed, but I'd prefer if it could just somehow know if it's there without my manual intervention, which leads me to believe that #if won't work for this situation. Is there another way

Conditional compilation when using ARC

柔情痞子 提交于 2019-12-01 04:07:46
Is there a way to ask the compiler if ARC is turned on, and then conditionally compile based upon that value? For example, I have a protocol: @protocol ProtocolA @required -(void)protocolMethodOne @optional -(void)protocolMethodTwo; @end If I'm using ARC, I would like to make protocolMethodA optional when using ARC, and required when not using ARC. This is because one of the main reasons for utilizing this method is to dealloc the object instance. With that said, here's what I would like to happen: @protocol ProtocolA #ifdef SOME_ARC_VARIABLE @optional #else @required #endif -(void

Checking for availability of C++0x algorithm additions

主宰稳场 提交于 2019-11-30 23:59:51
I'm trying to figure out which of the additions to the algorithm headers are supported by a given implementation (gcc and MSVC would be enough). The simple way would be to do it the same way as one would do it for core features: check the compiler version and define a macro if a language feature is supported. Unfortunately I cannot find a list that shows the version numbers for either compiler. Is simply checking for a generic C++0x macro (GXX_EXPERIMENTAL or __cplusplus) enough or should I check the change lists for the compilers and build my macros based on those lists? http://gcc.gnu.org

When does #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) in dxvahd.h Microsoft header file become true

泪湿孤枕 提交于 2019-11-30 20:50:14
Hi I am having 2 VC++ solutions "A" & "B" (VS2008) both are having the same codebase (with just few lines of code different). Using DXVAHD.h in both. dxvahd.h is a standard Microsoft header file. If we open this header file, we see there is a conditional if " #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) " I see that in VC++ solution "A", the above conditional #if statement is false, hence the whole dxvahd header file gets greyed out & is not even compiled!! Whereas in another solution "B", this conditional #if is true,hence no issues & its working fine. Can anyone kindly let me know

Checking for availability of C++0x algorithm additions

十年热恋 提交于 2019-11-30 18:57:50
问题 I'm trying to figure out which of the additions to the algorithm headers are supported by a given implementation (gcc and MSVC would be enough). The simple way would be to do it the same way as one would do it for core features: check the compiler version and define a macro if a language feature is supported. Unfortunately I cannot find a list that shows the version numbers for either compiler. Is simply checking for a generic C++0x macro (GXX_EXPERIMENTAL or __cplusplus) enough or should I