conditional-compilation

Can I #define a constant solutionwide within c# code without project settings?

十年热恋 提交于 2019-12-08 10:39:59
问题 I know this was aksed and answered a a couple of times e.g. Solution-wide #define, Is There anyway to #define Constant on a Solution Basis? and How to define a constant globally in C# (like DEBUG). But in my case I can not use any of the suggested methods: I'm writing on different "modules" (or plugins if you want so) for UnityProjects (kind of a package providing a certain functionality). The idea is that a developer can load a certain "module" to use in his project by importing a

Debugging with my own custom Class Libraries

风流意气都作罢 提交于 2019-12-08 07:19:12
问题 I want my class library conditionally compiled so that it is in debugging mode when my project is, and is not when my project isn't. For example, I have this Module in my class library: Module MyDebug <Conditional("DEBUG")> Sub print(ByVal msg As String) Debug.Print(Now.ToString("yyyy-MM-dd HH:mm:ss.fff") & " " & msg) End Sub <Conditional("DEBUG")> Sub debugEnd(Byval bool As Boolean) Environment.Exit(0) End Sub End Module When I debug my project which references this library it run any of

Visual Studio 2012 - location of Conditional Compilation Symbols settings

£可爱£侵袭症+ 提交于 2019-12-08 02:39:30
问题 I cannot for the life of me find the field where I'm meant to input the conditional compilation symbols for a project in Visual Studio 2012. I'm new to this feature so I don't know if it's been renamed something else, but I'm trying to follow this guide but I get stuck at picture #4. I can't find a Build tab in the project properties, let alone the conditional compilation symbols field. I'm in a C++ project if that makes a difference. I've looked in documentation and Googled it to no avail.

How to conditionally compile a newer Indy feature?

江枫思渺然 提交于 2019-12-07 12:12:41
问题 I've already found this answer on how to check the Indy version at run-time, and there are multiple different ways. However I'm looking how to use conditionals to check the Indy version at compile-time. There's a feature in newer versions of Indy, and I want my open-source project to use this feature if it's available. But I need to conditionally compile it. I've found IdVers.inc , but this file only contains constants - no version conditionals. More specifically, the TIdHTTP has a property

Conditional compilation symbols not being defined

旧巷老猫 提交于 2019-12-07 06:49:26
问题 I am having trouble getting Visual Studio to behave as I would expect it. I created 2 configuration profiles. One has the symbol FOO defined and the other has the symbol BAR defined. And I have this code: static class MyClass{ #if FOO public static string const MyData="foo defined"; #endif #if BAR /*yes, I know #elif would work here too.. just trying to be simple*/ public static string const MyData="bar defined"; #endif } and then later in another file I have if(MyClass.MyData=="foo defined")

How to get rid of ifdef's in a large c project

梦想的初衷 提交于 2019-12-07 05:53:43
问题 I got my hands on a opensource project coded in C . It uses #ifdef's for cross-compiling. There are a lot of ifdef's all over the source code. I want just to modify it for one platform. I was thinking to run it through compiler's pre-processor (Visual C++) but it will write the preprocessed result to a single file, which I don't need. Anybody knows a way to pre-process a project leaving it's structure intact (all files intact)? No grep, please. edit: I found a potential solution (it's amazing

Conditional DEBUG - Does it still compile into RELEASE code?

故事扮演 提交于 2019-12-07 02:44:15
问题 I know that if I mark code as DEBUG code it won't run in RELEASE mode, but does it still get compiled into an assembly? I just wanna make sure my assembly isn't bloated by extra methods. [Conditional(DEBUG)] private void DoSomeLocalDebugging() { //debugging } 回答1: Yes, the method itself still is built however you compile. This is entirely logical - because the point of Conditional is to depend on the preprocessor symbols defined when the caller is built, not when the callee is built. Simple

Is it better to use `#ifdef` or inheritance for cross-compiling?

≯℡__Kan透↙ 提交于 2019-12-07 02:38:45
问题 To follow from my previous question about virtual and multiple inheritance (in a cross platform scenario) - after reading some answers, it has occurred to me that I could simplify my model by keeping the server and client classes, and replacing the platform specific classes with #ifdefs (which is what I was going to do originally). Will using this code be simpler? It'd mean there'd be less files at least! The downside is that it creates a somewhat "ugly" and slightly harder to read Foobar

Visual Studio 2012 - location of Conditional Compilation Symbols settings

别来无恙 提交于 2019-12-06 08:30:38
I cannot for the life of me find the field where I'm meant to input the conditional compilation symbols for a project in Visual Studio 2012. I'm new to this feature so I don't know if it's been renamed something else, but I'm trying to follow this guide but I get stuck at picture #4. I can't find a Build tab in the project properties, let alone the conditional compilation symbols field. I'm in a C++ project if that makes a difference. I've looked in documentation and Googled it to no avail. Thanks! Chro Ok so someone else I asked has found the solution: Go to Project properties > Configuration

How to obtain debug/release conditional compiling in C++ program

爷,独闯天下 提交于 2019-12-06 04:24:45
问题 In a large C++/Qt/QMake/qtcreator project I would like to perform some tests, but only when I am compiling with the debug flag. Is there a way to tell g++ that some small parts of the code have to be compiled only in debug mode ? 回答1: The standard way to do this is to depend on the macro NDEBUG , which is used by the macro assert() defined in <cassert> : #ifdef NDEBUG // release mode code #else // debug mode code #endif The opposite of #ifdef is #ifndef , and of course #else branches are