macros

How to make a preprocessor macro greedy?

回眸只為那壹抹淺笑 提交于 2020-01-24 05:47:10
问题 We have the following preprocessor macro. Its used to help with Doxygen documentation because Doxygen has troubles with C++ and some template typedefs: #if defined(DOXYGEN_PROCESSING) # define DOCUMENTED_TYPEDEF(x, y) class y : public x {}; #else # define DOCUMENTED_TYPEDEF(x, y) typedef x y; #endif It works great when X is a non-template or has only one template parameter. However, if X is a template with multiple parameters: DOCUMENTED_TYPEDEF(Foo<R,S>,Bar); Then it results in compile

SAS: Execute SAS code using hotkey

女生的网名这么多〃 提交于 2020-01-24 00:53:07
问题 I want to execute code which is independent of my current program via keyboard shortcuts within the Enhanced Editor in SAS 9.4 for Windows. I've achieved this with limited success being able to execute only macro statements. However, I want to be able to execute non-macro statements, too. How do I do this? Here's what I've figured out so far. General Setup Get to the KEYS menu by either entering "KEYS" into the command prompt or submitting dm 'keys'; For one of the keys, enter the definition

Map macro in MSVC 2010

穿精又带淫゛_ 提交于 2020-01-24 00:27:08
问题 I have code, that taken from https://github.com/swansontec/map-macro/blob/master/map.h : #define EVAL0(...) __VA_ARGS__ #define EVAL1(...) EVAL0 (EVAL0 (EVAL0 (__VA_ARGS__))) #define EVAL2(...) EVAL1 (EVAL1 (EVAL1 (__VA_ARGS__))) #define EVAL3(...) EVAL2 (EVAL2 (EVAL2 (__VA_ARGS__))) #define EVAL4(...) EVAL3 (EVAL3 (EVAL3 (__VA_ARGS__))) #define EVAL(...) EVAL4 (EVAL4 (EVAL4 (__VA_ARGS__))) #define MAP_END(...) #define MAP_OUT #define MAP_GET_END() 0, MAP_END #define MAP_NEXT0(test, next, ...

Metamorphic Example Code

◇◆丶佛笑我妖孽 提交于 2020-01-23 17:37:29
问题 So I've been working on implementing the metamorphic code example from James Holderness found here: Metamorphic Code Examples. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <time.h> #define PUSH 0x50 #define POP 0x58 #define MOV 0xB8 #define NOP 0x90 #define ADD 0x01 #define AND 0x21 #define XOR 0x31 #define OR 0x09 #define SBB 0x19 #define SUB 0x29 #define JUNK asm __volatile__(PUSH,NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,POP) #define JUNKLEN 8 const unsigned

Metamorphic Example Code

怎甘沉沦 提交于 2020-01-23 17:37:26
问题 So I've been working on implementing the metamorphic code example from James Holderness found here: Metamorphic Code Examples. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <time.h> #define PUSH 0x50 #define POP 0x58 #define MOV 0xB8 #define NOP 0x90 #define ADD 0x01 #define AND 0x21 #define XOR 0x31 #define OR 0x09 #define SBB 0x19 #define SUB 0x29 #define JUNK asm __volatile__(PUSH,NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,POP) #define JUNKLEN 8 const unsigned

A macros in the C language (#define)

我怕爱的太早我们不能终老 提交于 2020-01-23 09:15:51
问题 I am reading source code of hoard memory allocator, and in the file of gnuwrapper.cpp, there is the following code #define CUSTOM_MALLOC(x) CUSTOM_PREFIX(malloc)(x) What's the meaning of CUSTOM_PREFIX(malloc)(x) ? is CUSTOM_PREFIX a function? But as a function it didn't defined anywhere. If it's variable, then how can we use variable like var(malloc)(x) ? More code: #ifndef __GNUC__ #error "This file requires the GNU compiler." #endif #include <string.h> #include <stdlib.h> #include <stdio.h>

A macros in the C language (#define)

只谈情不闲聊 提交于 2020-01-23 09:14:04
问题 I am reading source code of hoard memory allocator, and in the file of gnuwrapper.cpp, there is the following code #define CUSTOM_MALLOC(x) CUSTOM_PREFIX(malloc)(x) What's the meaning of CUSTOM_PREFIX(malloc)(x) ? is CUSTOM_PREFIX a function? But as a function it didn't defined anywhere. If it's variable, then how can we use variable like var(malloc)(x) ? More code: #ifndef __GNUC__ #error "This file requires the GNU compiler." #endif #include <string.h> #include <stdlib.h> #include <stdio.h>

Is there a relationship between untyped/typed code quotations in F# and macro hygiene?

最后都变了- 提交于 2020-01-23 07:20:31
问题 I wonder if there is a relationship between untyped/typed code quotations in F# and the hygiene of macro systems. Do they solve the same issues in their respective languages or are they separate concerns? 回答1: Quotations are a form of meta-programming. They allow you to manipulate abstract syntax trees programmatically, which can be in turned spliced into code, and evaluated. Typed quotations embed the reified type of the AST in the host language's type system, so they ensure you cannot

How do I access the _context variable within a macro in TWIG?

主宰稳场 提交于 2020-01-23 05:31:08
问题 I'm trying to access one of my twig variables in a macro. I know I can't do this directly. as with PHP functions, macros don't have access to the current template variables but the same page state: You can pass the whole context as an argument by using the special _context variable. What's the syntax for passing _context to the macro, and for accessing it within the macro? thanks 回答1: Consider the following example: 1) Create a variable in the current context {% set x = 42 %} 2) Declare a

In clojure, how can I evaluate the arguments to a macro from another macro?

会有一股神秘感。 提交于 2020-01-23 05:29:13
问题 I have two macros. The first one takes a symbol as the only parameter (because it's passed to def, which needs a symbol). The second function takes a list of symbols and should call the first with each symbol individually. (defmacro m1 [s] '(let [f# ... dynamic function definition ...] (def ~s f#)) The second macro should take a list of symbols and pass them to the first, but I can't get it to work. The best I could come up with was the following: (defmacro m2 [symbols] `(for [s# ~symbols]