Questions tagged [macros]

***DO NOT USE for VBA / MS-Office languages. Use [vba] instead.*** A macro is a rule or pattern that specifies how a certain input sequence (often a sequence of characters) should be mapped to an output sequence (also often a sequence of characters) according to a defined procedure.

macros
Filter by
Sorted by
Tagged with
0 votes
1 answer
170 views

Need to fix my Variadic Macros

I want to use variadic macros but I get errors #define SERVER_RE_1(ServerFunction, Type1) \ { \ ...
Ufx's user avatar
  • 2,665
0 votes
1 answer
34 views

Can I make macro like `MACRO(x, Type1 t1, Type2 t2)`

I want to make my code smaller. I think some macros could make my code smaller. I want to make macro which contains objects declarations. There are switch cases case SIGN_UP: { std::...
Ufx's user avatar
  • 2,665
1 vote
1 answer
280 views

error when vim macro recording play

I know how to record a macro use vim. eg. record macro a: in normal mode, qa start recording, do some action, q stop recording. If I want to play it, I can use @a. Now I want to play 10 times, 10@a ...
jim ying's user avatar
  • 381
6 votes
2 answers
224 views

Is that possible to get comments with macro?

I was trying to parse some code and reformat them, but it seems that quote will just ignore the comments. Is there any way to achieve this? I guess I have to dive into the erlang side?
Kabie's user avatar
  • 10.6k
-1 votes
1 answer
52 views

How to make function or macros for any count of arguments with any types?

There are client and server. I send and receive data using boost::serialization. Often several arguments with different types send. Are there ways to make function or macros for this? For example ...
Ufx's user avatar
  • 2,665
0 votes
1 answer
1k views

nasm, macro print not working as expected

I'm calling a function written in assembly from a C file. The c code passes two pointers to the assembly function. I'm using the print macro into the assembly to check the value of the addresses and ...
AR89's user avatar
  • 3,578
0 votes
1 answer
644 views

Php to .xlsm (Macro enabled files)

I am trying to use PhpExcel library to export data to an .xlsm file.I know the macro enabled files are not officially supported. Does anyone know how to do it?Or an other way around?
JustVF's user avatar
  • 1
2 votes
1 answer
88 views

Assembly macro check argument

Well, a new strange problem occurred within assembly (especially tasm) CheckInfo MACRO arr:REQ, length:REQ, arr_type := <l> mov bx, arr mov cl, length mov si, 1 IF arr_type eq &...
Olexiy  Pyvovarov's user avatar
2 votes
1 answer
82 views

Run a macro from grunt in PhpStorm/WebStorm?

I'd like to run recorded PhpStorm/Webstorm macros via grunt to perform post-build tasks in the IDE. Is there a way to do this and/or run macros from the command-line?
Lorenz Lo Sauer's user avatar
1 vote
1 answer
2k views

ImageJ "There are no images open"

I have the following code, which works fine except that when I try to close the ROI Manager and montage at the end I get the error: There are no images open I started without specifying the ...
user3470496's user avatar
1 vote
1 answer
982 views

Is C variadic macro able to expand ##__VA_ARGS__ recursively?

variadic macro mentioned about VA_ARGS for gcc. I did the following experiment. #define EVAL(f,...) eval(f,build_args(args,__VA_ARGS__ , args_end)) And EVAL(f,a) // => eval(f,build_args(args,a,...
wcy's user avatar
  • 895
13 votes
1 answer
570 views

Advantages of do { } while(0) versus ({ }) in a macro?

There are plenty of questions on Stack Overflow regarding the use of do { ... } while(0) in macros, but this is a bit different. I understand why do { ... } while(0) is used to wrap multiple lines of ...
Alex D's user avatar
  • 30.1k
1 vote
2 answers
142 views

How to use a parameter in a macro call?

I have defined the following simple macro: (defmacro define-class (class-name) `(defclass ,class-name ()())) And now I want to use it in the following function: (defun create-data (mode) (...
Xaving's user avatar
  • 329
0 votes
0 answers
96 views

Button not fired up inside asp user control used for umbraco macro

I'm searching solutions for my problem already since 2-3h and I decided better to ask. I have created and empty web site and the installed umbraco, set up a new macro and it seemd ok but a button is ...
David's user avatar
  • 127
0 votes
2 answers
2k views

Expand define macro with include macro

I'm trying to define a macro. The idea is that when it expands, it'll include a header. For example: #define function() \ include <CustomHeader.h> Thanks a lot.
sigifredo's user avatar
  • 152
5 votes
4 answers
867 views

macro for switching between auto_ptr and unique_ptr

In a project that still uses pre-C++11 I wanted to prepare the source for the switch by compiling with a C++11 compiler and fixing the errors. They consisted of instances of std::auto_ptr<T> ...
rwst's user avatar
  • 2,615
0 votes
1 answer
2k views

call a function from a header file

I have a question regarding header files in C. I need to initialize a variable but depending on a condition. In order to evaluate that condition I need to call a function, see code below: I have the ...
Maverick's user avatar
2 votes
1 answer
661 views

Can macros mimic void returning functions by casting to void?

So... I have macros, that has "SET" functionality and shall mimic a function, that would return void. I could use a do {...} while(0) construct to implement this behavior, but is it legal, and if so ...
Mark A.'s user avatar
  • 589
0 votes
2 answers
11k views

Expanded from macro 'num' while printing it using printf by Clang compiler

Code: char *color_name[] = { "red", "blue", "green" }; #define color_num (sizeof(color_name)/sizeof(char*)) int main(){ printf("size %d \n",color_num); return 0; } It works ...
MMMMMCCLXXVII's user avatar
1 vote
1 answer
278 views

Creating a macro in haml that changes the children or parent element

I have the following haml pattern that I use very often: %p.wording{:'data-wording-key' => 'some.key'} = Wording.fetch('some.key') I wonder if I can create a helper or macro to write it as %p{...
Benjamin Crouzier's user avatar
2 votes
1 answer
407 views

Case sensitive string comparison Image J Macro

String comparisons are case insensitive using Image J Macro. For example, the following will print "True": if ("c" == "C") { print("True"); } Does anyone know of a workaround to make case-...
RainbowMonkey's user avatar
1 vote
1 answer
988 views

Evaluating an expression of type shapeless.Witness.Aux[T] in a macro fails

I'm trying to evaluate an implicit parameter of type shapeless.Witness.Aux[T] in a macro in order to use the value of the singleton type T. This is a minimal example: import shapeless.Witness import ...
Frank S. Thomas's user avatar
-5 votes
2 answers
205 views

Doubts about Macros in C

#define MHZ *1000000l #define MSEC /1000l This is the function defination unsigned int SysTick_Config(unsigned int ticks) { if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); // Reload value ...
tapan chawda's user avatar
3 votes
1 answer
3k views

More than one listenFor tag in Speech Macro XML

I recently started getting into windows Speech Macros, it allows you to make custom commands for windows Voice Recognition. Currently, I've only been able to say 1 thing to it, and it could respond ...
Cubit-Games's user avatar
0 votes
1 answer
610 views

md5sum value changes every time I compile cuda source code

I was trying to verify if my macro really works during compilation by md5sum command in ubuntu. For example, by "nvcc -DTEST_MACRO ...." I got an executable A. Then by "nvcc ..." I got an executable ...
Leo's user avatar
  • 43
5 votes
2 answers
327 views

Contextual eval in clojure

Here is an example from joy of clojure chapter 8: (defn contextual-eval [ctx expr] (let [new-expr `(let [~@(mapcat (fn [[k v]] [k `'~v]) ...
qed's user avatar
  • 22.7k
1 vote
1 answer
3k views

Is there a Visual Studio Project Configuration Macro which defines DEBUG or RELEASE regardless of the Project Configuration Name?

I saw that its a very common thing to use the Visual Studio Macro called $(Configuration) for build file paths. For example if you create a new Visual C++ Project in Visual Studio 2013 your default ...
Vinz's user avatar
  • 3,137
1 vote
0 answers
69 views

how does macro-generating macro work in clojure

Here is a macro-generating macro I learned from #clojure channel: (defmacro import-alias [new-name imported] `(defmacro ~new-name [f# & body#] `(. ~'~imported ~f# ~@body#))) (pprint (...
qed's user avatar
  • 22.7k
1 vote
1 answer
200 views

IllegalStateException in nested quote and unquote

Here is an example from joy of clojure: (let [x 9, y '(- x)] (println `y) (println ``y) (println ``~y) (println ``~~y)) Output from repl: typedclj.macros/y (quote typedclj.macros/y) ...
qed's user avatar
  • 22.7k
0 votes
1 answer
752 views

C++: complex function-like macro definition

While reading node.js source code, I came across a macro that I just can't understand. // Strings are per-isolate primitives but Environment proxies them // for the sake of convenience. #define ...
plafer's user avatar
  • 185
6 votes
2 answers
1k views

Macro that defines functions whose names are based on the macro's arguments

*Note: Despite having frequented StackOverflow for a long time, this is the first question that I have posted myself. Apologies if it's a bit verbose. Constructive criticism appreciated. When I ...
Andy Page's user avatar
  • 315
-3 votes
1 answer
34 views

In which situation does this macro can cause an error?

Consider the following macro #define SQ(x) ((x) * (x)); In which situation does using this macro cause an error?
Elimination's user avatar
  • 2,691
4 votes
1 answer
7k views

Wrong macros definition casuses "Expected expression" error

I have these macros: #define TRUE 1; #define FALSE 0; I want to use them in an if condition, for example: if (functionThatReturnsIntZeroOrOne() == FALSE) do_something(); but I get such an error ...
mario razzu's user avatar
2 votes
4 answers
1k views

Do macros run faster than global variables in C? How to change macros between runs?

I'm writing a program in C in which there are several constants I would like all of my functions to use. So far, I have used macros. A simplified version of the program looks as follows. #define ...
Plamen's user avatar
  • 650
4 votes
2 answers
4k views

__has_cpp_attribute not a 'function-like' macro?

I am attempting to introduce the [[deprecated]] attribute into my codebase. However, not all the compilers I am required to support have support for this syntax yet (the various method used by ...
MuertoExcobito's user avatar
2 votes
1 answer
986 views

Can't forward parameters to nested macros

I am working on Rust macros to generate a static array of structures that describe FFI callbacks. What I currently have is... // some trivial callback functions extern "C" fn my_fun_1(argc: u32, ...
goertzenator's user avatar
  • 2,010
0 votes
4 answers
467 views

Assigning UIColor values to macros

This question refers to this SO post: How to set global variable with UIColor class The accepted answer suggests defining a macro like so: AppDelegate header: // AppDelegate.h #import <UIKit/...
iSofia's user avatar
  • 1,442
1 vote
2 answers
17k views

macro error: A character operand was found in the %EVAL function or %IF condition

%macro test(k); %if &k le 0 %then %put < 0 ; %else %put > 0; %mend test; %test(-5); %test(3.1); But %test(-3.1); will generate error ERROR: A character operand was found in the %EVAL ...
Lovnlust's user avatar
  • 1,527
-2 votes
2 answers
81 views

use definitions in loop (c coding)

I have definitons like #define COLUMN1 1 #define COLUMN2 2 #define COLUMN3 a #define COLUMN4 b I want to use them in a loop for (int var = 0; var < 3; ++var) { if(COLUMNvar) .... ; // ...
Saim Neftci's user avatar
1 vote
2 answers
114 views

How do I display pre-processed macro (just user defined) using gcc?

I know "gcc -E main.c" option gives all the values pre-processed output. Is there a way to just expand the user defined macros? For example #define MACRO(z) z+z c = a + (MACRO(z)) When I use this ...
howtechstuffworks's user avatar
6 votes
3 answers
197 views

Unrecognized C macro

I've come across a macro defined in a C header file that I'm having a little bit of trouble understanding. #if BAR #define FOO(s,err) \ ((SOMEPOINTER)(s))->VALID != SOMEVARIABLE \ ...
Chris's user avatar
  • 61
0 votes
1 answer
1k views

Finding components of constraint in Catia via macro

does anyone know hot to get information via Catia macros about component (planes, faces, axis etc.) used in making constraint?
Mpr's user avatar
  • 1
0 votes
2 answers
2k views

Defining constant-variables with a C macro

I am trying to define a 'variable' with a macro which can later be used as a constant value ...I have now run out of ideas and wondering if anyone can tell me if I've missed anything: This is what I ...
BlueChip's user avatar
  • 161
2 votes
1 answer
664 views

Average in assembly 8086 (macro error)

The code below computes the average of 20 user entered numbers. It works fine when I disable ShowMsg msg2 (make it a comment), but when its enabled, I get this error : INT 21h, AH=09h - address: ...
Asnira's user avatar
  • 313
2 votes
1 answer
384 views

CMake error in macro with target_link_libraries

I wrote a macro that calls the function TARGET_LINK_LIBRARIES: macro(Link_Libs cur_target) #ATLAS LIBS on Linux add_library(ptlapack STATIC IMPORTED) set_property(TARGET ptlapack PROPERTY ...
Oleg's user avatar
  • 21
1 vote
2 answers
97 views

Strange syntax in macro definition [C]

I'm new to C, and currently reading through driver code that I have to alter. I came across a wall of text with lines like: #define IOCTL_AIO ('i'<<8) #define ...
IronMage's user avatar
3 votes
2 answers
235 views

Where and When should we use compile time macro concatenation?

I've seen this bit of code which I thought was great because it saved me from re-writing getter member functions. #define GET(n_,N_) \ template<typename T> ...
user avatar
1 vote
1 answer
112 views

What is the difference between executing a macro and executing the contained instructions within it in Teradata?

Sometimes it can well be observed that individual instructions within a macro execute way faster than a whole macro in Teradata ? Is this just a delusion or is there any logic behind it ? I am newbie ...
StrugglingCoder's user avatar
3 votes
2 answers
1k views

Importing a common constant declared pig file in other pig files

Objective : Have defined constants (%declare and %default) statements in constants.pig for code modularity and to import the same in other pig files. As per docs : http://pig.apache.org/docs/r0.12.0/...
Murali Rao's user avatar
  • 2,287
3 votes
1 answer
1k views

Swift equivalent of #define to retrieve list of variable arguments

So I have a function in C that works as #define PRINTF(format) { va_list list; va_start(list, format); vprintf(format, list);} void foo(const char* format, ...) { PRINTF(format) } I was ...
Kunal's user avatar
  • 83

1
158 159
160
161 162
275