conditional-compilation

Is conditional compilation a valid mock/stub strategy for unit testing?

In a recent question on stubbing, many answers suggested C# interfaces or delegates for implementing stubs, but one answer suggested using conditional compilation, retaining static binding in the production code. This answer was modded -2 at the time of reading, so at least 2 people really thought this was a wrong answer. Perhaps misus...

Is it possible in .Net to call some code only from debug builds of client assemblies?

I am writing a (very small) framework for checking pre- and postconditions of methods. Entry points are (they could be easily be methods; that doesn't matter): public static class Ensures { public static Validation That { get { ... } } } public static class Requires { public static Validation That { get { .....

Conditional compilation depending on the framework version in C#

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? ...

Is possible to include files (linking) based on a component property ?

Delphi 2007/2009 odd question here: It's possible, based on a component property defined in design-time, to include files in linking or leave them ? Example: If I leave SomeProperty true, when compiling, the unit SomeUnit will be included into my project. Otherwise it will not be included. My second approach to this problem is to depl...

Conditional compilation in Python

How to do conditional compilation in Python ? Is it using DEF ? ...

How to conditionally compile VC6 resources

Hi, depending on a compile switch (values are COMPILE_A or COMPILE_B), which is set in the form of an envorinment variable, I want to compile my application with different settings, like application name and splash screen. I got this far: In "Project / Settings / C/C++ / Preprocessor Definitions" I added $(COMPILESWITCH) (results in...

How can I manage multiple configurations of a single Haskell program?

What is an alternative to autotools in Haskell world? I want to be able to choose between different configurations of the same source code. For example, there are at least two implementations of MD5 in Haskell: Data.Digest.OpenSSL.MD5 and Data.Digest.Pure.MD5. I'd like to write code in such a way that it can figure out which library is ...

Can you include only certain forms during a compile

We are developing two versions of an application. Not in the sense of a lite vs standard version of the application, where one version will have limited functionality etc. We will actually be displaying different types of information in the application, depending on the version (that's the best way I can describe it without going into to...

Conditional References

Currently our .net code is not processor specific, but it depends on libraries (Oracle/ODP.Net) which are. We've found a solution where we edit the csproj file directly, and put the references in to item groups with a Condition clause based on our selected build configuration. We have 32 bit debug/release and 64bit debug/release, and t...

Conditional compilation in C++ based on operating system

I would like to write a cross-platform function in C++ that contains system calls. What conditional compilation flags can I check to determine which operating system the code is being compiled for? I'm interested mostly in Windows and Linux, using Visual Studio and GCC. I think it should look something like this: void SomeClass::SomeFu...

What is difference between Release and Debug modes in Visual Studio?

HI I want to know what's the difference between Release and Debug modes in Visual Studio while building a project? Thanks in Advance. ...

Why is /clr incompatible with /mt and /mtd in Visual Studio?

Hi can anybody please explain for me how and why /clr is incompatible with /mtd ? What is the alternative for this? What happens internally if I use /md or /mdd ? As far as I know we don't combinedly use /clr and /mtd. Can someone explain if there is a way to do this? And please explain me how and why /clr is incompatible with /mt and ...

How to use /NODEFAULTLIBS option in compilation ?

Hi i hav solution explorer contains 2 proj.for one project i enable /clr with /mdd. for parent project i hav /mtd and no clr support.when i compiling this i am getting two linker errors including the below one Link warning link 4098:Default lib can conflict with other lib use /NODEFAULTLIBS library so my question how to use /NOD...

How to resolve linking error??

Hi I hav a project.it shows error only with linking only. it displays __getch alresdy defined evnthough i hav ignored specific library MSVCR80D.dll it shows error. Plz Help me in this regard..... after using /verbose: Processed /DEFAULTLIB:msvcprtd Processed /DEFAULTLIB:MSVCRTD Processed /DEFAULTLIB:OLDNAMES Processed /DEFAULTLIB:M...

compile different code on whether a function is available or not

Windows provides only GetTickCount up to Windows Vista and starting from that OS also GetTickCount64. How can I make a C program compile with calls to different functions? How can I make a C compiler check whether a function is declared in the included header files and compile different portions of code depending on whether that particu...

Using MSBuild Conditions on COMReferences

How can I specify a Condition for a COMReference in my *.csproj file? The following does not appear to work: <COMReference Include="SomeComLib" Condition=" '$(Configuration)' == 'Debug' "> ... </COMReference> I have some COM references in a C# project in Visual Studio 2008. I would like them to automatically use non-isolation mode...

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

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? ...

VS2008: How do I make symbols defined in stdafx.h visible to the resource compiler?

I am working on a VC++ project under VS2008. My resource files contain some pre-processor directives for conditional compilation. Some of the symbols controlling the conditional compilation are defined in stdafx.h. I need these symbols to be visible to the resource compiler as well. How do I make this happen? ...

Delphi 2007 and {$IFDEF...} directive, fails to see our conditional

We have the following in our codebase, in a component file: {$IFDEF ADO} FDatabase : TADODatabase; {$ELSE} FDatabase : TODBCDatabase; {$ENDIF} The reason is that for various legacy applications, one or the other type of database connection and set of classes is to be used. However, while configuring a new machine, it seems that our c...

(Delphi) Check state of a switch directive in the function caller's environment

I know that I can check the current state of Delphi's switch directives using this construct: {$IFOPT R+} Writeln('Compiled with range-checking'); {$ENDIF} Since I'm lacking of in-depth sources on how the Delphi backend compiler works, I'm not sure wether there is a way of changing the behaviour of a function depending on the st...