conditional-compilation

Will the expression provided to Debug.Assert be evaluated in a release build?

拈花ヽ惹草 提交于 2019-12-22 08:11:40
问题 Say I have a rather expensive assertion: bool IsCompatible(Object x, Object y) { // do expensive stuff here } If I test this assertion with: Debug.Assert(IsCompatible(x,y)); Will IsCompatible be executed in release builds? My understanding is that Debug.Assert being marked as [Conditional("DEBUG")], calls to it will only be emitted in debug builds. I'm thinking that this won't prevent the expression from being evaluated in release mode though, since the method call may have side effects, only

gcc conditional compilation

放肆的年华 提交于 2019-12-22 06:36:03
问题 I'm learning about conditional compilation and I think that I understand it well so far. Now, if I have the code: #ifdef UMP_TO_FILE //do something here... #endif and I run: gcc myprogram.c -DUMP_TO_FILE Then, the code block "//do something here..." gets compiled. Now, my question is: What exactly the -DUMP_TO_FILE flag does? I think that the flag is "-D" and it defines the macro "UMP_TO_FILE", but I want to be sure of the syntaxis and "gcc --help" does not tell me anything about this and

#ifdef with multiple tokens, is this legal?

白昼怎懂夜的黑 提交于 2019-12-22 06:32:27
问题 Today I came across some C++ code that contains an #ifdef clause like this: #ifdef DISABLE_UNTIL OTHER_CODE_IS_READY foo(); #endif Note the space between "DISABLE_UNTIL" and "OTHER_CODE_IS_READY". Essentially there are two tokens specified in the #ifdef line. My question is, is this legal C++ code? (g++ compiles it without any errors, and it apparently just ignores the second token). And if it is legal, should the second token have any effect? 回答1: [C++11 16.1] , [C++11 16.5] and,

Conditional compilation for .NET 4 [duplicate]

[亡魂溺海] 提交于 2019-12-22 04:32:23
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Conditional compilation and framework targets I have some code that works in .NET 4, but it does not work in .NET 3.5. In .NET 3.5 it requires to use interop calls to Windows. I would like using a "ifdef" to use a different code path in both cases (eventually I will deprecate the .NET 3.5 code). Is there a pre-defined directive value to identify when the code is compiled with .NET 4? Is there a good link with

ignore ios8 code in xcode 5 compilation

一笑奈何 提交于 2019-12-21 20:58:57
问题 I've got a team working on some IOS code. One developer (me) has Xcode6-beta with a few lines of IOS8 specific code. When another developer with Xcode5 builds it for IOS7, compilation fails, because the IOS8 SDK doesn't exist for him. if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){ // ios8 code } else { // ios7 and less way } Is there a way to ignore the IOS8 code in Xcode compilation based on the SDK or Xcode version, such that it compiles? 回答1: Yes, you can do this using

Conditional Compilation in Referenced Assemblies

▼魔方 西西 提交于 2019-12-21 12:37:17
问题 I'm writing an assembly with some conditionally compiled members in it, e.g.: [Conditional("DEBUG")] public static void Log(string message) { /*...*/ } And using it like so: public void DoStuff() { Log("This will only appear on debug builds"); /* ... Do stuff ... */ } But when I give this assembly to someone to use in their project, I want them to be able to define whether or not DEBUG-conditional members are compiled. If that's not possible (e.g. the methods are just completely removed at

How to define conditional compilation symbols in separate file (not .csproj or app.config)

守給你的承諾、 提交于 2019-12-21 04:50:53
问题 We need to define a conditional compilation symbol in a class library project. This should not be checked in the source control (it doesn't apply to all developers), so it should be defined in someplace other than the .csproj or the app.config file. How can this be achieved? 回答1: I would define your various build types in the configuration manager (menu Build → Configuration Manager ) and set up each of the required constants on each of the build types. You can then have each member of the

C# shortcut for #if … #else … #endif like #define something as string

亡梦爱人 提交于 2019-12-20 07:26:21
问题 In C# dotNET for Mono, is there an easier way of doing this? #if __MonoCS__ public static SqliteConnection NewConnection #else public static SQLiteConnection NewConnection #endif In C I would be able to #if and then #define something, #else and define it as something else. I know that the C# preprocessor doesn't allow what I want, but is there a simpler way of coping with the differences between SQLite for Windows and Linux? Thanks, Jim Thanks to those who answered. Files that depend on

Conditional compilation when using ARC

牧云@^-^@ 提交于 2019-12-19 06:19:19
问题 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