preprocessor

Gfortran pre-processor directives for Different Operating systems

≯℡__Kan透↙ 提交于 2019-11-28 12:32:36
Could you tell me please how can I do the following: #if __unix__ #define path_sep='/' #elif __windows__ #define path_sep='\' #else #error "path_sep not defined." #endif using gfortran compiler. This can be done in combination with conditional compilation and using the "D" option on the command line. Here is some example code: program test_Dopt character (len=1) :: pathsep pathsep = "?" #ifdef WOS pathsep = "\" #endif #ifdef UOS pathsep = "/" #endif write (*, '( "pathsep is >", A1, "<")' ) pathsep end program test_Dopt Name the program with filetype F90 to cause gfortran to run the

What are the gcc predefined macros for the compiler's version number?

时间秒杀一切 提交于 2019-11-28 06:49:09
I have run into a bug with gcc v3.4.4 and which to put an #ifdef in my code to work around the bug for only that version of the compiler. What are the GCC compiler preprocessor predefined macros to detect the version number of the compiler? DigitalRoss From the gnu cpp manual... __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ These macros are defined by all GNU compilers that use the C preprocessor: C, C++, Objective-C and Fortran. Their values are the major version, minor version, and patch level of the compiler, as integer constants. For example, GCC 3.2.1 will define __GNUC__ to 3, __GNUC_MINOR

How do you implement “#ifdef” in python?

那年仲夏 提交于 2019-11-28 06:16:53
Programming in C I used to have code sections only used for debugging purposes (logging commands and the like). Those statements could be completely disabled for production by using #ifdef pre-processor directives, like this: #ifdef MACRO controlled text #endif /* MACRO */ What is the best way to do something similar in python ? If you just want to disable logging methods, use the logging module. If the log level is set to exclude, say, debug statements, then logging.debug will be very close to a no-op (it just checks the log level and returns without interpolating the log string). If you want

How do I define preprocessor macros in Xcode 4?

我怕爱的太早我们不能终老 提交于 2019-11-27 19:23:48
I have two targets set up for my app (a lite version and a pro version) and I want to integrate some subtle differences in the code for each of them (e.g. the pro version will not show any iAd banners). I have been looking around and I see the easiest way to do this is through the use of preprocessor macros. The issue I'm facing is how to set them up in Xcode 4. I want to set up a macro called 'PRO_VERSION' in one target & 'LITE_VERSION' in the other. Below is an example of how I intend to use them: #ifdef PRO_VERSION // Hide ad banners #else // Show ad banners #endif The build setting you

PHP closing tag deletes the line feed

我只是一个虾纸丫 提交于 2019-11-27 18:11:22
问题 I'm doing an experiment, an html preprocessor like SLIM or Jade. This is the PHP code that seems right: nav ul id: "test" li @<?= $Var; ?> li @About li @Contact This is the expected pre-processed html (yes, $Var == "Test"): nav ul id: "test" li @Test li @About li @Contact However, in the browser I get this wrong text as the pre-processor html : nav ul id: "test" li @Test li @About li @Contact Lastly, there are two ways to make it correct. Adding the break line manually: nav ul id: "test" li @

What is the difference between - 1) Preprocessor,linker, 2)Header file,library? Is my understanding correct?

≡放荡痞女 提交于 2019-11-27 11:20:05
问题 Okay, until this morning I was thoroughly confused between these terms. I guess I have got the difference, hopefully. Firstly, the confusion was that since the preprocessor already includes the header files into the code which contains the functions, what library functions does linker link to the object file produced by the assembler/compiler? Part of the confusion primarily arose due to my ignorance about the difference between a header file and a library. After a bit of googling, and stack

How would you do the equivalent of preprocessor directives in Python?

ε祈祈猫儿з 提交于 2019-11-27 11:11:38
Is there a way to do the following preprocessor directives in Python? #if DEBUG < do some code > #else < do some other code > #endif There's __debug__ , which is a special value that the compiler does preprocess. if __debug__: print "If this prints, you're not running python -O." else: print "If this prints, you are running python -O!" __debug__ will be replaced with a constant 0 or 1 by the compiler, and the optimizer will remove any if 0: lines before your source is interpreted. Evan Plaice I wrote a python preprocessor called pypreprocessor that does exactly what you're describing. The

Add preprocessor macro to a target in xcode 6

梦想与她 提交于 2019-11-27 07:13:20
Probably this is pretty simple, but I can't find a way to define a preprocessor macro for a target in Xcode 6. I've done a screenshot to show where it is in Xcode, because it's easier :) Select project file Select the target you want Go to Build Settings Search for 'preprocessor' Add your preprocessor macro either for Debug, Release, or both. In Xcode 9 you have to add a preprocessor macros to Project, not Target. Also don't forget to add "D" as the firs letter. For example, "DDebug", then it works. 来源: https://stackoverflow.com/questions/26928622/add-preprocessor-macro-to-a-target-in-xcode-6

Gfortran pre-processor directives for Different Operating systems

Deadly 提交于 2019-11-27 07:05:09
问题 Could you tell me please how can I do the following: #if __unix__ #define path_sep='/' #elif __windows__ #define path_sep='\' #else #error "path_sep not defined." #endif using gfortran compiler. 回答1: This can be done in combination with conditional compilation and using the "D" option on the command line. Here is some example code: program test_Dopt character (len=1) :: pathsep pathsep = "?" #ifdef WOS pathsep = "\" #endif #ifdef UOS pathsep = "/" #endif write (*, '( "pathsep is >", A1, "<")'

How do I override a Python import?

a 夏天 提交于 2019-11-27 06:49:05
I'm working on pypreprocessor which is a preprocessor that takes c-style directives and I've been able to make it work like a traditional preprocessor (it's self-consuming and executes postprocessed code on-the-fly) except that it breaks library imports. The problem is: The preprocessor runs through the file, processes it, outputs to a temporary file, and exec() the temporary file. Libraries that are imported need to be handled a little different, because they aren't executed, but rather they are loaded and made accessible to the caller module. What I need to be able to do is: Interrupt the