conditional-compilation

C Preprocessor Macros - conditionals based upon argument concatenation

牧云@^-^@ 提交于 2019-12-13 04:35:00
问题 I need help with macros, please! Suppose I’ve got the following constants defined #define foo_tacos_tuesday 1 #define foo_tacos 1 #define foo_nachos_wednesday 2 #define foo_nachos 3 I’d like to write a macro that does the following #define MyFancyMacro( arg1, arg2 ) \ #if ( foo_ ## arg1 ## _ ## arg2 != foo_ ## arg1 ) \ foo_ ## arg1 ## _ ## arg2, foo_ ## arg1, So I can set up a mapping table that only maps the mismatching values: static const int mappingTable[] = { MyFancyMacro(tacos, tuesday)

“has_trivial_destructor” defined instead of “is_trivially_destructible”

穿精又带淫゛_ 提交于 2019-12-12 10:42:42
问题 During the refinement process of the C++11 standard, it seems that is_trivially_destructible was considered a better/more-consistent name than has_trivial_destructor. This is a relatively recent development, as my g++ 4.7.1 still uses the old name, and it's been fixed to be compliant with the standard as of 4.8: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52702 I've been lazily using an #if which favors the compiler I'm on: #if TRIVIAL_DESTRUCTOR_TYPE_TRAIT_MATCHES_STANDARD template<class T>

Debug mode or Release mode

跟風遠走 提交于 2019-12-12 10:06:42
问题 Recently, I'm working on intergrating the physics engine into my graphics engine program. Before this, I always build my program in Debug mode because I feel Debug means safe and more information to let me know where is wrong. In my program, I built Assimp in Release mode, but I still used it in the Debug mode until now. For now, I build Bullet Physics in Release mode beacuse of the performance is huge different in Debug mode. If you want to know how slow it is, you could see this. The

How to define version “and up” ifdefs in Delphi?

给你一囗甜甜゛ 提交于 2019-12-12 08:19:03
问题 I was working on getting Log4D working in Delphi XE4, and was getting some compile errors because it couldn't find Contnrs in the uses clause, unless I moved it outside the ifdef it was defined in. {$IFDEF DELPHI5_UP} Contnrs, {$ENDIF} A little bit of investigating uncovered that the ifdef is defined in an included file Defines.inc which has a block for each "supported" version of delphi which stops a few versions back: eg: {$IFDEF VER170} { Delphi 2005 } {$DEFINE DELPHI9} {$DEFINE DELPHI4_UP

conditional compliation based on variable into makefile

喜夏-厌秋 提交于 2019-12-12 05:37:17
问题 Inside my C/C++ code I would like to include or not a file depending on different compilation. For the moment I use this: #ifndef __x86_64__ #include <myLib.h> #endif this gives me the possibility of doing whether the platform is 32/64 bit but does not give me enough freedom. I would like to pass a variable to my makefile like make includeMyLib=1 and depending on this having something like: #ifndef includeMyLib #include <myLib.h> #endif Do you know if anything like this is possible? 回答1: If

Can I use conditional compilation to add missing types?

烂漫一生 提交于 2019-12-11 14:56:14
问题 The following: #If False Then Public Type Long LoPart As Integer HiPart As Integer End Type #End If Throws a compiler error "Expected: Identifier" when run on my VBA7 32-bit office (Excel). This is because Long is a protected type. However, it was my understanding that the compiler should not see what's in the block (since the condition is always false). Why do I still get the error? I can still write and run code using Long variables - my type doesn't show up in intellisense. But the line

Problems with ifdef based inheritance in C++

久未见 提交于 2019-12-11 12:26:22
问题 I was looking at the code of some class I was using, and I came across code like this: #ifdef SOME_OBSCURE_CONDITION class A { #elif class A : public B { #endif Can there be any problems with such code? Specifically, suppose file x.cpp includes y.h and z.h. z.h and y.h both include a.h (which defines class A), but additionally y.h defines SOME_OBSCURE_CONDITION. In this case, will two conflicting definitions of A not be present in x.cpp? 回答1: yes, the two variations simultaneously would

How to mark use statements for conditional compilation? [duplicate]

↘锁芯ラ 提交于 2019-12-11 12:08:53
问题 This question already has answers here : How do I exclude a file from being built on OS X? (2 answers) Example of how to use Conditional Compilation Macros in Rust (1 answer) Is there a list of all cfg features? (3 answers) Closed 10 months ago . Is it possible to mark certain includes to only get included on relevant OS's? For example, can you do something like: #[cfg(unix)] { use std::os::unix::io::IntoRawFd; } #[cfg(windows)] { // https://doc.rust-lang.org/std/os/unix/io/trait.AsRawFd.html

Is it possible to conditionally compile a code block inside a function?

丶灬走出姿态 提交于 2019-12-11 05:59:10
问题 I'm wondering if something like this is possible fn main() { #[cfg(foo)] { println!("using foo config"); } } The context is some code that cannot adequately be tested with just unit tests. I'll often have to run a "demo" cfg which displays information. I'm looking for alternatives to manually commenting in/out some portions of code. 回答1: As of at least Rust 1.21.1, it's possible to do this as exactly as you said: fn main() { #[cfg(foo)] { println!("using foo config"); } } Before this, it isn

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

感情迁移 提交于 2019-12-11 04:07:31
问题 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 conditionals aren't taken into account. In the project settings, it says "ADO;DEBUG", and yet it compiles the above code with the odbc type instead. The odd thing