conditional-compilation

Cython conditional compilation based on external value given via `setuptools`

浪尽此生 提交于 2019-12-19 04:05:09
问题 I try to conditionally generate C code from a Cython pyx file. I found in the Cython documentation that I can use DEF to define a value and IF to conditionally generate code based on a defined value, but how can I set the value from the setup.py via Extension from setuptools . Thank You 回答1: Thank you for the link. The interesting flag in the setup.py is cython_compile_time_env . And to import the Extension from Cython. from setuptools import setup from Cython.Distutils.extension import

Conditional Compilation - Check Scheme

↘锁芯ラ 提交于 2019-12-18 07:17:12
问题 In a Swift project before I've been able to perform a simple compiler check to see which scheme is running, then conditionally include code or not. For example: #if MyScheme Add code here #endif But for some reason, in my Objective-C project, this doesn't seem to be working. Should this work the same way? Or does the Swift compiler have some advancements which allow this kind of behaviour? 回答1: Use #ifdef //example for debug scheme #ifdef NDEBUG Add code here #endif And you can define your

Conditional compilation in C++ based on operating system

我是研究僧i 提交于 2019-12-18 06:13:10
问题 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::SomeFunction() { // Other code #ifdef LINUX LinuxSystemCall(); #endif #ifdef WINDOWS WindowsSystemCall(); #endif // Other code } 回答1: My gcc (4.3.3) defines the

How do I check if one of multiple macros is defined in a single #ifdef?

给你一囗甜甜゛ 提交于 2019-12-18 03:56:51
问题 I have some C++ code, and want to perform an action if the __APPLE__ or __linux macros are defined. If I did it as a normal if conditional, it would be easy using || : if (something || something) { .. code .. } But as of what I know there is no || operator for #ifdef statements. How would I check if __APPLE__ or __linux is defined using a single #ifdef statement? 回答1: You can't in a single #ifdef would a single #if do instead? #if defined(__APPLE__) || defined(__linux) this also works if you

How to programmatically change conditional compilation properties of a VBA project

只愿长相守 提交于 2019-12-18 02:18:38
问题 I'm currently working on a VBA code generator/injector that adds VBA functionality to Excel workbooks by using the VBA Extensibility. This all works fine. However, the original code that is injected uses conditional compilation, referring to some global conditional compilation arguments: Is there any way I can programmatically modify/add the conditional compilation arguments of a VBA project? I checked all properties of the VBProject but couldn't find anything. 回答1: Inspired by this approach,

Use #ifdefs and #define to optionally turn a function call into a comment

这一生的挚爱 提交于 2019-12-17 15:56:24
问题 Is it possible to do something like this #ifdef SOMETHING #define foo // #else #define foo MyFunction #endif The idea is that if SOMETHING is defined, then calls to foo(...) become comments (or something that doesn't get evaluated or compiled), otherwise it becomes a call to MyFunction. I've seen __noop used, but I don't believe I can use that. EDIT(s): I don't think I can really use a macro here, because MyFunction takes a variable number of arguments. Also, I'd like to make it so the

Change name of exe depending on conditional compilation symbol

馋奶兔 提交于 2019-12-17 09:55:43
问题 Can you tell Visual Studio to output a different name of an exe file depending on if a specific conditional compilation symbol is set? 回答1: 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

Conditional compilation in Python

。_饼干妹妹 提交于 2019-12-17 09:44:15
问题 How to do conditional compilation in Python ? Is it using DEF ? 回答1: Python isn't compiled in the same sense as C or C++ or even Java, python files are compiled "on the fly", you can think of it as being similar to a interpreted language like Basic or Perl. 1 You can do something equivalent to conditional compile by just using an if statement. For example: if FLAG: def f(): print "Flag is set" else: def f(): print "Flag is not set" You can do the same for the creation classes, setting of

How to use /NODEFAULTLIBS option in compilation?

女生的网名这么多〃 提交于 2019-12-13 12:32:01
问题 I have a solution explorer contains 2 projects. For one project I have enabled /clr with /mdd . For parent project I have /mtd and no clr support. When I compile this I get two linker errors including the below one: Link warning link 4098:Default lib can conflict with other lib use /NODEFAULTLIBS library So my question is how to use /NODEFAULTLIBS in compilation. Thanks in advance. 回答1: First you need to work out which library is causing the conflict, if you can. Does the link warning tell

Debug Mode In VB 6?

廉价感情. 提交于 2019-12-13 11:53:03
问题 How can I do something similar to the following C code in VB 6? #ifdef _DEBUG_ // do things #else // do other things #end if 回答1: It's pretty much the same as the other languages that you're used to. The syntax looks like this: #If DEBUG = 1 Then ' Do something #Else ' Do something else #End If It's easy to remember if you just remember that the syntax is exactly the same as the other flow-control statements in VB 6, except that the compile-time conditionals start with a pound sign ( # ). The