preprocessor

How to write conditional import statements in QML?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 04:08:09
Like we have preprocessor directives in C++ for conditional includes. Similarly, how to do conditional import ing in QML? if x import ABC 1.0 else import PQR 2.0 Depending on what you want to achieve, a possible workaround is to use a Loader. But it does not import a module, it just allows to choose dynamically which QML component you'll use. Loader { source: condition?"RedRectangle.qml":"BlueRectangle.qml" } extending a little bit the @Yoann answer: Loader { source: x?"ABC.qml":"PQR.qml" } where ABC.qml : import ABC 1.0 ... and PQR.qml : import PQR 2.0 ... or if don't what to have real qml

PHP closing tag deletes the line feed

你。 提交于 2019-11-29 04:05:23
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 @<?= $Var . "\n"; ?> li @About li @Contact Writing a space after the PHP closing tag (??). Why is the

EXTENDS challenge: preprocessor function macros and class-like oop

感情迁移 提交于 2019-11-29 03:27:12
问题 Background I've been using the C preprocessor to manage and "compile" semi-large javascript projects with multiple files and build targets. This gives full access to C preprocessor directives like #include , #define , #ifdef , etc. from within javascript. Here's a sample build script so you can test the example code: #!/bin/bash export OPTS="-DDEBUG_MODE=1 -Isrc" for FILE in `find src/ | egrep '\.js?$'` do echo "Processing $FILE" cat $FILE \ | sed 's/^\s*\/\/#/#/' \ | cpp $OPTS \ | sed 's/^[#

Test for empty macro definition

冷暖自知 提交于 2019-11-29 03:05:21
I've got a set of debug macros in tracing.hh. Whether it generates code and output is controlled by a macro flag in the real source code: // File: foo.cc #define TRACING 0 #include "tracing.hh" // Away we go . . . TRACEF("debug message"); The flag TRACING should have a value; I usually toggle between 0 and 1. Within tracing.h, #ifdef TRACING will tell me that tracing was defined. #if TRACING controls the definition of functional macros like TRACEF() But what if TRACING has no value? Then #if TRACING produces an error: In file included from foo.c:3: tracing.hh:73:12: error: #if with no

Test for empty macro definition

折月煮酒 提交于 2019-11-29 03:03:37
I've got a set of debug macros in tracing.hh. Whether it generates code and output is controlled by a macro flag in the real source code: // File: foo.cc #define TRACING 0 #include "tracing.hh" // Away we go . . . TRACEF("debug message"); The flag TRACING should have a value; I usually toggle between 0 and 1. Within tracing.h, #ifdef TRACING will tell me that tracing was defined. #if TRACING controls the definition of functional macros like TRACEF() But what if TRACING has no value? Then #if TRACING produces an error: In file included from foo.c:3: tracing.hh:73:12: error: #if with no

Discover the class of a methodinvocation in the Annotation Processor for java

戏子无情 提交于 2019-11-28 22:01:45
I am writing some tools for our build system to enforce some strict calling conventions on methods belonging to classes containing certain annotations. I'm using the Compiler Tree API... What i'm wondering is when traversing the 'tree', how can you tell the type of class/interface for a MethodInvocation. I'm subclassing TreePathScanner with : @Override public Object visitMethodInvocation(MethodInvocationTree node, Trees trees) { } I'm hoping theres a way to tell the type of the class(or interface) that you're trying to invoke the method on. Am I going about this the wrong way? Thanks for any

How to detect compilation by Android NDK in a C/C++ file?

社会主义新天地 提交于 2019-11-28 20:50:47
问题 Is there a preprocessor macro that will let me know NDK is compiling my code? I could manually define my own, but I'd rather not if possible. 回答1: It is #ifdef __ANDROID__ as seen by running the preprocessor: ~$ /usr/local/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc -E -dM - < /dev/null | grep -i android The output is: #define __ANDROID__ 1 No need to depend on defining stuff in your project especially if you're skipping the NDK build

Maven example of annotation preprocessing and generation of classes in same compile process?

倖福魔咒の 提交于 2019-11-28 18:26:06
Does anyone have a clean example of a maven project preprocessing class annotations at compile time with subsequent generation of classes to be compiled in the same compilation process? Does anyone have a step-by-step procedure to implement such a project? Jérôme Verstrynge After navigating a lot in existing documentation on the net, I came up with the following: What needs to be clarified: In order to process annotations on a given project P, you first need an annotation processor compiled in a separate library S. P should have a dependency on S. Implementing annotation processing in Java 5

Java Preprocessor

余生颓废 提交于 2019-11-28 17:45:59
If I have a boolean field like: private static final boolean DEBUG = false; and within my code I have statements like: if(DEBUG) System.err.println("err1"); does the Java preprocessor just get rid of the if statement and the unreachable code? Most compilers will eliminate the statement. For example: public class Test { private static final boolean DEBUG = false; public static void main(String... args) { if (DEBUG) { System.out.println("Here I am"); } } } After compiling this class, I then print a listing of the produced instructions via the javap command: javap -c Test Compiled from "Test.java

Can CPP preprocessing statement in Fortran be indented?

穿精又带淫゛_ 提交于 2019-11-28 14:31:05
I am fairly new to use Fortran preprocessing statement and have a question which is probably pretty native. Can Fortran preprocessing statement be indented? I tested using Gfortran 4.8.1 on Linux (openSUSE Leap) and it turned out I it can not be indented at all. The following code main.f90 works with gfortran -cpp main.f90 -o main : program main implicit none #ifdef DEBUG print *, "I am in debug mode" #endif print *, "hello world!" end program main But the following throws an error: program main implicit none #ifdef DEBUG print *, "I am in debug mode" #endif print *, "hello world!" end program