conditional-compilation

Change name of exe depending on conditional compilation symbol

假装没事ソ 提交于 2019-11-27 09:28:35
Can you tell Visual Studio to output a different name of an exe file depending on if a specific conditional compilation symbol is set? If you load the .csproj file into a text editor, you can control the AssemblyName property: <AssemblyName Condition="'$(Configuration)' == 'Debug'">WindowsFormsApplication9.Debug</AssemblyName> <AssemblyName Condition="'$(Configuration)' != 'Debug'">WindowsFormsApplication9</AssemblyName> Note though that this does not only change the file name, but the assembly name , which might mean trouble if you have other code referencing the assembly. I never did this

What #defines are set up by Xcode when compiling for iPhone

孤者浪人 提交于 2019-11-27 06:03:46
I'm writing some semi-portable code and want to be able to detect when I'm compiling for iPhone. So I want something like #ifdef IPHONE_SDK... . Presumably Xcode defines something, but I can't see anything under project properties, and Google isn't much help. Airsource Ltd It's in the SDK docs under "Compiling source code conditionally" The relevant definitions are TARGET_OS_IPHONE (and he deprecated TARGET_IPHONE_SIMULATOR), which are defined in /usr/include/TargetConditionals.h within the iOS framework. On earlier versions of the toolchain, you had to write: #include "TargetConditionals.h"

Tools to generate unit dependencies for Delphi

我与影子孤独终老i 提交于 2019-11-27 03:21:35
问题 Are there any tools that can generate dependency diagrams for Delphi units taking into account conditional compilation directives. I'd like to emphasize that this should be unit dependency diagram, not class dependency. Also it would be nice to have the ability to rearrange and hide some parts in the generated diagram. I've tried Understand and it doesn't seem to do what I want. 回答1: I personally use the free Project Dependencies from GExperts . It does not display a diagram, but as a tree

C# !Conditional attribute?

徘徊边缘 提交于 2019-11-27 01:26:22
问题 Does C# have a not Conditional ( !Conditional , NotConditional , Conditional(!) ) attribute? i know C# has a Conditional attribute: [Conditional("ShowDebugString")] public static void ShowDebugString(string s) { ... } which is equivalent 1 to: public static void ShowDebugString(string s) { #if ShowDebugString ... #endif } But in this case i want the inverse behavior (you have to specifically opt out ): public static void ShowDebugString(string s) { #if !RemoveSDS ... #endif } Which leads me

Preprocessor directives across different files in C#

我与影子孤独终老i 提交于 2019-11-26 21:35:47
问题 I know that I can use preprocessor directives in C# to enable/disable compilation of some part of code. If I define a directive in the same file, it works fine: #define LINQ_ENABLED using System; using System.Collections.Generic; #if LINQ_ENABLED using System.Linq; #endif Now, I'm used in C++ at putting all this configuration directives inside a single header file, and include it in all files where I need such directives. If I do the same in C# something doesn't work: //Config.cs #define LINQ

Is it possible to conditionally compile to .NET Framework version?

冷暖自知 提交于 2019-11-26 21:11:55
问题 I can recall back when working with MFC you could support multiple versions of the MFC framework by checking the _MFC_VER macro. I'm doing some stuff now with .NET 4 and would like to use Tuple in a couple of spots but still keep everything else 3.5 compatible. I'm looking to do something like: #if DOTNET4 public Tuple<TSource, TResult> SomeMethod<TSource, TResult>(){...} #else public KeyValuePair<TSource, TResult> SomeMethod<TSource, TResult>(){...} #endif 回答1: There are no builtin

Which conditional compile to use to switch between Mac and iPhone specific code?

痞子三分冷 提交于 2019-11-26 19:14:37
问题 I am working on a project that includes a Mac application and an iPad application that share code. How can I use conditional compile switches to exclude Mac-specific code from the iPhone project and vice-versa? I've noticed that TARGET_OS_IPHONE and TARGET_OS_MAC are both 1, and so they are both always true. Is there another switch I can use that will only return true when compiling for a specific target? For the most part, I've gotten the files to cooperate by moving #include <UIKit/UIKit.h>

Conditional compilation depending on the framework version in C#

六眼飞鱼酱① 提交于 2019-11-26 18:55:21
Are there any preprocessor symbols which allow something like #if CLR_AT_LEAST_3.5 // use ReaderWriterLockSlim #else // use ReaderWriterLock #endif or some other way to do this? Frederick The Fool I don't think there are any predefined 'preprocessor' symbols. However you can achieve what you want like this: Create different configurations of your project, one for every version of CLR you want to support. Choose a symbol like VERSION2 , VERSION3 etc. per CLR version. In every configuration, define the one symbol associated with it and undefine all others. Use these symbols in conditional

How do I change a function's qualifiers via conditional compilation?

给你一囗甜甜゛ 提交于 2019-11-26 17:52:29
问题 I have a function that is capable of being implemented as a const : #![feature(const_fn)] // My crate would have: const fn very_complicated_logic(a: u8, b: u8) -> u8 { a * b } // The caller would have: const ANSWER: u8 = very_complicated_logic(1, 2); fn main() {} I'd like to continue to support stable Rust where it's not possible to define such functions. These stable consumers would not be able to use the function in a const or static , but should be able to use the function in other

Conditional Java compilation

我只是一个虾纸丫 提交于 2019-11-26 16:58:44
问题 I'm a longtime C++ programmer, new to Java. I'm developing a Java Blackberry project in Eclipse. Question - is there a way to introduce different configuration sets within the project and then compile slightly different code based on those? In Visual Studio, we have project configurations and #ifdef; I know there's no #ifdef in Java, but maybe something on file level? 回答1: You can set up 'final' fields and ifs to get the compiler to optimize the compiled byte-codes. ... public static final