FAQ Database Discussion Community


c++ concatenating macro definitions

c++,macros,concatenation,preprocessor
In C++ (G++ to be specific), can one concatenate two macro definitions, without spaces, to create a 3rd definition? For example, how to I take #define _LOAD _mm256_load #define _FLOAT ps and operate on them thusly #define _LOAD_FLOAT ****do something with _FLOAT and _LOAD here ***** to create a definition...

create a macro in sas

macros,sas
I have a report that is generated once a year. each report has the form of the year inside the name - report-2011.xls, report-2012.xls etc. each report contains the following vars: ID, SAL=average monthly salary of that year, Gender (0=male, 1=female), Married (0=not married, 1=married), I need to create a...

%mend statement in SAS macro

macros,sas
%macro A1(input); [balala] %mend A1; %macro A1(input); [balala] %mend; I just realized both ways work for defining a macro. Is there any difference between these two?...

How to use a parameter in a macro call?

macros,lisp,common-lisp,sbcl
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) (define-class mode)) After compiling the last function I get the following message, the variable MODE is defined but never used. And when I...

C++ / C #define macro calculation

c++,c,macros
Suppose I have #define DETUNE1 sqrt(7)-sqrt(5) #define DETUNE2 sqrt(11)-sqrt(7) And I call these multiple times in my program. Are DETUNE1 and DETUNE2 calculated every time it is called? Thanks. Please don't downvote this, I really want to know and a search didn't turn up anything definite. ...

C++ Macro Magic: getting for every macro parameter, the parameter count number

c++,macros
I've to write a lot of code like this. foo.setArg(0, arg_0); foo.setArg(1, arg_1); ... foo.setArg(n, arg_n); Where n is compile-time specific and the arg_n are of different types; I want a variadic macro which i can call like this MACRO_MAGIC(arg_0,arg_1,...,arg_n) I know how to get the total number of arguments...

Macro to push arguments onto stack

visual-c++,assembly,macros
I've been working on a fun little project to mess around with how functions are called and I need a macro to push arguments as it'll be quite time consuming to push the arguments manually for every instance of this obfuscated call. This is my code so far: #define pushargs(...)...

clojure quoting inside let

clojure,macros,eval
Quoting (both syntax and non-syntax) seems to fail to detect vars inside a let statement: (let [foo 1] (eval `(print foo))) This will generate an error or use whatever prior value bound was bound to foo in (def foo bar). Is there a way to make the syntax quote use...

Why don't I get a warning when I declare a variable with same name in a macro that already exists in a function?

c,macros,ansi
Playing with a macro and thought about the following scenario. Declaring variable in a macro which already exists in function from which this macro has been called, why compiler doesn't complain. When I declare in a code a variable it give me a warning: Redefinition of 'temp' I think that...

Providing new version of existing macro with parameters

c++,macros,overloading
We have an existing log macro in our code. Lets call it LOG_XXX where XXX is the log level to use, such as LOG_INFO, LOG_DEBUG, LOG_ERROR etc. We stream log messages to the macro: LOG_INFO << "This is a log message."; Under the covers, the macro creates a temporary object...

Importing a common constant declared pig file in other pig files

import,macros,apache-pig
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/cont.html#import-macros, %declare and %default are valid statements in a macro. Issue Faced : Pig is not able to find the declared parameter. Pig...

Defining Macros that are equal to functions that return objects in C++

c++,static,macros,singleton
So I have the singleton pattern working the way I want to, I think the main problem is something with pointers and refrences. ("..." represents irrelevent code). Universe.h ... #define TheUniverse Universe::GetInstance (); ... public: static Universe& GetInstance (); ... private: static Universe* x_instance; ... Universe.cpp ... Universe* Universe::x_instance =...

How do you replace the first and last line in Notepad++?

macros,notepad++
I'm trying to make a macro that does some replacements and in the end, deletes the first and the last lines in the document, but I've hit a dead end. Any advice?

calling multiple macros from another macro in C++

c++,macros
Hi i have a question about the use of macros in C++. If i have two macros defined and create a third one like this: #define MAC1(X) {something here} #define MAC2(X,Y) {something here} So now third one is defined like this: #define MAC3(X,Y) MAC1(X); MAC2(X,Y) Can you please clarify how...

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

macros,common-lisp,symbols,sbcl
*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 define a struct in Common Lisp using defstruct, a predicate function is automatically generated that tests whether its argument is...

Accessing argument's metadata in Clojure macro

clojure,macros
Is there a way to retrieve the metadata of the arguments inside a clojure macro without using eval? The only thing I could come up with so far is this: (def ^{:a :b} my-var) (defmacro my-macro [s] (prn (eval `(meta (var ~s))))) (my-macro my-var) ;; Prints {:a :b, :name my-var,...

How to test whether an identifier that is accessible only through a #define macro is defined?

c++,c,macros
I have a #define mapping an identifier (a function name) to a new name like this: #define A doStuff This part I cannot do anything about, I have to access "A" since the actual identifier (doStuff here) may change (and this is not under my control). Now the referenced symbol...

Understanding NASM Macro

assembly,macros,ffmpeg,nasm
I've come around this macro in a assembly source file and I just can't figure out how it's working. So first I come around this function (hevc_deblock.h): cglobal hevc_v_loop_filter_chroma_8, 3, 5, 7, pix, stride, tc, pix0, r3stride sub pixq, 2 lea r3strideq, [3*strideq] mov pix0q, pixq add pixq, r3strideq TRANSPOSE4x8B_LOAD...

Append the string provided by __FUNCTION__ macro

c++,macros
I have defined a macro as following: #define ADD_TIME_ENTRY(_name_) m_pTimeMeasurement->addTimeEntry(_name_); Now, I want to pass the function name through ADD_TIME_ENTRY() in whichsoever function I put ADD_TIME_ENTRY() ADD_TIME_ENTRY(__FUNCTION__) works fine for me but now, I want to add "_start" or "_stop" at the end of the function name. I mean, I...

syntax error : missing ')' before 'constant'

c,compiler-errors,macros,syntax-error,c-preprocessor
I have some syntax problems that I don't know how to fix. I'm trying to build some functions to matrix, can someone help me resolve those problems? 1>c:\documents and settings\one\my documents\visual studio 2010\projects\hw3\hw3\q2.c(11): error C2143: syntax error : missing ')' before 'constant' 1>c:\documents and settings\one\my documents\visual studio 2010\projects\hw3\hw3\q2.c(11): error C2143:...

Elisp: how to make this function short

emacs,macros,elisp
I am implementing an plugin, which a lot of project types are remembered. For example: angular, meteor, ember, rails ... And keyed arguments are used. The function creates an hash table with provided keys and values, and assign the hash table to another hash table. Code below: (defun jst-remember-project-type (type...

Command Pattern persistence and Serialization

c#,serialization,macros
I want to record a sequence of commands to a data store and save them so I can replay them on the store later. I have a command interface: interface ICommand { void Execute(); } I have different classes implementing the ICommand, say class Create: ICommand {...} class Update: ICommand...

How to share same header files between kernel modules and userspace applications.

linux-kernel,macros,linux-device-driver,header-files,ioctl
I want to implement a simple module in which an ioctl() method is used. In the kernel module, I use kernel macros, such as _IO(), _IOWR(), etc., to define my own ioctl sub-commands. In facts, I don't care the actual values of these definitions for that I will always use...

doxygen misrendering macro type as public member function

c,macros,doxygen
I'm using a type macro list(type) which expands to a dynamic type [ list_of_type ] like below : main snippet ... #define list(type) force_append_macro(list_of_,type) ... typedef struct _improperlydocumented { list(char_ptr) *words; }improperlydocumented; ... problem doxygen is incorrectly rendering this type [ list(char_ptr) ] as a public member function ( instead...

Too many warnings on a C macro

c,gcc,macros,warnings
I'm trying an approach to flag warnings on my code, but I did some mistake and can't understand where. My compiler gives me too much warnings about each use of this macro: #define MPL_ERROR_MESSAGE2(output, fmt, ...) fprintf(output, ("\n[ERROR][%s:%d( %s )]\n--- " fmt " ---\n\n"), __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); #define MPL_ERROR_MESSAGE(fmt,...

defining recursive values C

c,macros
#define BLOCK_OFFSET(block) (BASE_OFFSET+(block-1)*block_size) usage lseek(fd, BLOCK_OFFSET(group->bg_inode_table)+(inode_no-1)*sizeof(struct ext2_inode),SEEK_SET); This is a fragment of a code im trying to understand and I have no idea how that definition works. Is it recursive? Can someone explain step by step whats happening in that lseek?...

How can I change the value stored in local macro from string to numeric in Stata?

types,macros,global,local,stata
I want to generate a variable with lagged year depending on the year stored in "$S_DATE" macro I have stored the year in date macro: . local date substr("$S_DATE",8,.) . display `date' 2015 And I want to generate the new variable with gen start_year =`date'- y_passed where y_passed is a...

Is there any way to skip macro replacement(During preprocessing) when macro is used as a variable name?

c++,qt,c++11,macros,qt5
ConflictHeader.h #define _c 6 //This is third party header, canot change, since // there is no sorce code to rebuild testclass.h #ifndef TESTCLASS_H #define TESTCLASS_H #include <QObject> #include "ConflictHeader.h"//Include conflicted header class TestClass : public QObject { Q_OBJECT public: TestClass(QObject *parent); ~TestClass(); private: }; #endif // TESTCLASS_H testclass.cpp #include "testclass.h"...

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

c,macros
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 code in a macro expansion. But there is another form...

how to apply macro on list of lines with vim

linux,vim,macros
let's suppose I want to apply a macro stored on register 1 on lines: 2, 5, 9 but without applying on lines in between. I saw that you can give a range but that is not what I want. I've tried some variation on :2, 5, 9 @1 without success

Why is my C code printing out an extra line of rows?

c,loops,for-loop,macros,printf
#include <stdio.h> #define rows 500 //can define rows as any number int main() { int i,j; for(i=0;i<=rows;++i) { for(j=0;j<(2*i+1);++j) { printf("* "); } printf("\n"); } return 0; } So here is my code, what it does is it prints the number of rows set by #define and creates a right...

type of expanded C macro

c,macros,petsc
What type and value does PETSC_COMM_WORLD in the following header expand to? Is it just a redefinition for MPI_Comm with extern scope? #define PETSC_EXTERN extern PETSC_VISIBILITY_PUBLIC PETSC_EXTERN MPI_Comm PETSC_COMM_WORLD; ...

Backquote String Interpolation

macros,lisp,common-lisp
Is it possible to use lisp's macro to do string interpolation? For instance, can I make a macro like this: (defmacro test (a) `",a") So that (test abc) returns "abc" as a string? I could probably cheat by quoting it and turning that quote into a string, but that doesn't...

SAS Concatenate Multiple Variables to Create Data-Driven Macro Statements

sql,macros,sas,append,concatenation
In order to keep my process data-driven, I'm trying to concatenate multiple variables, separated by comma, in order to ultimately put them in a PROC SQL list to call in multiple macro statements that would otherwise clutter my SAS pogram. Take the following sample dataset: DATA TEST; INPUT YEAR CONDITION...

Defining macro function from makefile

c++,c,makefile,macros
Suppose I have following entry in my makefile: ifeq ($(MY_DEBUG),yes) EXTRACXXFLAGS += -DMY_DEBUG=2 endif I am invoking it with make foo MY_DEBUG=yes and now I basically have #define MY_DEBUG 2 for all project files available. Question: Can I define the macro function all over the project this way, without including...

macro for switching between auto_ptr and unique_ptr

c++,c++11,macros,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> replaced with std::unique_ptr<T> where necessary, wrapped the smart pointer with std::move() some 0 and NULL replaced with nullptr...

What does the non-terminating-p argument of set-macro-character do?

macros,common-lisp
Set-macro-character has an optional argument called non-terminating-p. It seems to be used to indicate whether another character should be read after reading the macro character, but the reader algorithm seems to ignore this argument. Is there a difference whether I set it to true or false?

Parentheses and macro overloading in C++

c++,macros
My codebase has an existing macro: #define SOME_MACRO <macro definition> For some changes I'm making, I want to add a new version of the macro that takes an argument. #define SOME_MACRO(arg1) <macro definition> I see that this question addresses selecting from multiple argument versions of a macro. However, the SOME_MACRO...

Appending postfix to function name with macros

c++,c,macros
I'm trying to figure out how to achieve the following: MACRO(foo, postfix, ...) ----> foo_postfix(__VA_ARGS__) There doesn't seem to be a straightforward way to do this....

Extract Argument from C Macro

c,macros,arguments,c-preprocessor
I have a number of definitions consisting of two comma-separated expressions, like this: #define PIN_ALARM GPIOC,14 I want to pass the second expression of those definitions (14 in the case above) to unary macros like the following: #define _PIN_MODE_OUTPUT(n) (1U << ((n) * 2U)) How can I extract the second...

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

macros,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 to Teradata and I will appreciate if someone explains the reasons from...

Why does this operation break when turned into a function (AutoHotKey/AHK)

function,com,macros,ms-office,autohotkey
The following operation works correcting inside AHK. It replaces the word ted with the word tom inside an open word document. Working Code ; Word Constants vbTrue := -1 wdReplaceNone := 0 wdFindContinue := 1 return #IfWinActive, ahk_exe WINWORD.EXE ^7:: try oWord := ComObjActive("Word.Application") catch return FindText := "ted" ReplaceWith...

“Joy of Clojure” 2 edition. Listing 11.9 about promises

clojure,macros,promise,mutation
I'm examining the Listing 11.9 of the named book (p.269 of pdf). Could anyone explain me how tests value is being set (line [tests all-tests :as results])? thanks...

use definitions in loop (c coding)

c,arrays,for-loop,macros
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) .... ; // var } Can I do like following: int col[4]={COLUMN1, COLUMN2, COLUMN3, COLUMN4};...

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

c,macros
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 CONSTANT 10 //int int multiplication_by_constant(int a){ return a*CONSTANT;} int main(){ for(int i =...

Wrong macros definition casuses “Expected expression” error

c,macros
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 message: "Expected expression". What do I do wrong?...

Scheme define-macro and/or define-syntax

macros,polymorphism,scheme,overloading
I want to create an overloaded Scheme macro for a simple form of polymorphism. That is, a macro smart enough to expand differently when given params of different types, so that (look-up key container) does the "right" thing for different kinds of containers. (define-macro (look-up key container) (cond ((table? container)...

Converting a case class to CSV in Scala

scala,csv,macros,case-class
Is there a elegant way to convert a case class to a CSV value. For example - case class Person( name : String, age : Int, gender: String, address : Option[String]) I was thinking about using macros but would like to know if there are any other alternatives. NOTE: The...

__has_cpp_attribute not a 'function-like' macro?

c++,gcc,macros,c++14
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 different compilers before standardization are described in the attribute standardization proposal N2761). Thus, I am attempting to conditionally...

how to add macro defines in Qt .pro file [duplicate]

c++,qt,macros
This question already has an answer here: How to add pre processing defs (macros) to qt creator? 3 answers I am now using asio alone in my project, which is supposed to be built as a shared library used by others. But I got the following error: warning Please...

How to determine macro value at compilation time in C?

c,compilation,macros,cc
If I have a macro in my C: #ifdef SIGDET #if SIGDET == 1 isSignal = 1; /*Termination detected by signals*/ #endif #endif How can I set the value at compilation time? Is it some parameter to the compiler?...

Introducing variables named by user in a macro

scala,macros,scala-macros
So I want to define a macro that introduces a couple of variables as variable declarations such that the names are defined by the user of the macro. Say that I want to be able to write something like the following. foldOver(0)(hd, rest)(List(1, 2, 3)) { hd + rest }...

Read input into string in Lisp reader macro

macros,common-lisp,reader-macro
I am trying to make a reader macro that would convert @this into "this". This is what I currently have: (defun string-reader (stream char) (declare (ignore char)) (format nil "\"~a\"" (read-line stream t nil t)) ) (set-macro-character #\@ #'string-reader ) The problem is that this requires that I put a...

Assigning UIColor values to macros

ios,objective-c,macros,global-variables,uicolor
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/UIKit.h> #define black = [UIColor blackColor] #define myColor = [UIColor colorWithRed:(238.0f/255.0f) green:(251.0f/255.0f) blue:(255.0f/255.0f) alpha:0.8f] @interface AppDelegate : UIResponder <UIApplicationDelegate> @end ViewController...

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

macros,sas,sas-macro
%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 function or %IF condition where a numeric operand is required. The condition was: &k le 0 I...

Can't forward parameters to nested macros

macros,rust
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, argv: *const i32) -> i32 { 1 } extern "C" fn my_fun_2(argc: u32, argv: *const i32) -> i32...

How to create a nnkUInt16Lit NimNode

macros,nim
There's no documentation on this except to describe the nnkUInt16Lit enum variant and this AST representation 42'i16 - nnkInt16Lit(intVal = 42). When I use it as we would with a regular nnkIntLit it fails. macro test(): stmt = var n = newNimNode(nnkUInt16Lit) n.intVal = 1 result = newLetStmt(ident("foo"), n) test()...

x-macro conditional error - number comparison

c,macros,x-macros
I would like to generate compile time error for X-macro for all X(a, b) where a > b /* X(a, b) */ #define LIST \ X(10, 20) \ X(5, 20) \ X(30, 20) \ X(1, 20) So, generate error for X(30, 20) Is this possible in C? EDIT: example usage...

Why do I have to expose a macro implementation's 'use' in the client library?

macros,rust
I'm trying to use a macro I've created in a separate module. With reference to this SO question, I've imported a macro fine. However it seems that I have Update to add macro implementation lib.rs #![macro_use] use std::fmt; use std::ffi::CString; use std::ffi::CStr; use std::str; extern crate libc; pub enum DbaxError...

How does this code print odd and even?

c,if-statement,macros,logic
#define MACRO(num, str) {\ printf("%d", num);\ printf(" is");\ printf(" %s number", str);\ printf("\n");\ } int main(void) { int num; printf("Enter a number: "); scanf("%d", &num); if (num & 1) { MACRO(num, "Odd"); } else { MACRO(num, "Even"); } return 0; } Please explain the above code (if/else condition and how...

In which situation does this macro can cause an error?

c,macros,preprocessor,c-preprocessor
Consider the following macro #define SQ(x) ((x) * (x)); In which situation does this macro can cause an error?...

Execute Macro inside SQL statement

sql,macros,sas,sas-macro
The Situation: I have a table mytable with two columns: tablename and tablefield: |-----------|------------| | tablename | tablefield | |-----------|------------| | table1 | id | | table2 | date | | table3 | etc | |-----------|------------| My core objective here is basically, make a Select for each of these tablenames,...

How to control C Macro Precedence

c,macros
#define VAL1CHK 20 #define NUM 1 #define JOIN(A,B,C) A##B##C int x = JOIN(VAL,NUM,CHK); With above code my expectation was int x = 20; But i get compilation error as macro expands to int x = VALNUMCHK; // Which is undefined How to make it so that NUM is replaced first...

call a function from a header file

c,function,macros,header
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 following function-like-macro in header.h where I need to call function(): #define func_like_macro()...

Julia: How do I create a macro that returns its argument?

macros,julia-lang
My question is quite similar to this one, but with a difference. I want to create a macro (or whatever) that behaves this way: julia> @my-macro x + 2 :(x + 2) (note that x + 2 is not enclosed in quotes). Is there something like that in Julia? And...

AutoHotKey macro scripting to open Outlook and create appointment

macros,autohotkey
I am new to AutoHotKey, I think it's a great tool for shortcuts. I would like to create a macro shortcut when I use a HotKey to create new meeting using Outlook that will pre-populate the to email address to a couple people and set the subject and location to...

clojure macro create || comparison?

clojure,macros
I want to create an || comparison with Clojure like other languages. (defmacro || [source & other] `(loop [s# [~source [email protected]]] (println s#) (let [fs# (first s#)] (if fs# fs# (if (= (count s#) 1) fs# (recur (next s#))))))) but this can't work. fs# value is quote data. like this...

Python-like C++ decorators

python,c++,function,macros,decorator
Are there ways to decorate functions or methods in C++ like in python style? @decorator def decorated(self, *args, **kwargs): pass Using macros for example: DECORATE(decorator_method) int decorated(int a, float b = 0) { return 0; } or DECORATOR_MACRO void decorated(mytype& a, mytype2* b) { } Is it possible?...

Need to fix my Variadic Macros

c++,c++11,macros,variadic-macro
I want to use variadic macros but I get errors #define SERVER_RE_1(ServerFunction, Type1) \ { \ Type1 arg1; \ getData(args, arg1); \ sv. ## ServerFunction ## (ssl, arg1); \ } #define SERVER_RE_2(ServerFunction, Type1, Type2) \ { \ Type1 arg1; \ Type2 arg2; \ getData(args, arg1, arg2); \ sv. ## ServerFunction...

Stata- Stopping at the variable before a specified variable in a varlist

macros,stata
I'm stuck on a tricky data management question, which I need to do in Stata. I'm using Stata 13.1. I have 40+ datasets I need to work on using a subset of variables that is different in each dataset. I can't include the data or specific analysis I'm doing for...

Picking up a certain string pattern without regex

c++,regex,c++11,macros
I have a scenario where I have a variety of C++ files with a specific macro: __EXTERNALIZE(Name, File) This macro is empty, it does nothing. But I want to write an external tool that scans one or many input files for this macro and do something once it finds that....

Combining multiple template classes to one class using typedef

c++,templates,macros,typedef
I have the following piece of code. Let us have the function declaration and implementation seperate. #include <iostream> class Y1 {}; class Y2 {}; template <class T1, class T2> class A { public: explicit A(); void foo() const; int bar() const; }; template <class T1, class T2> A<T1, T2>::A() {}...

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

c,gcc,macros,clang,c-preprocessor
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 fine with GCC 4.8.2 on Centos 7. But I got error running above program on mac which says: note:expanded from macro 'color_num' Compiler on my Mac: ……include/c++/4.2.1 Apple...

Can somebody explain this weird error in pig

hadoop,macros,apache-pig,hadoop2
I am using macros in pig , however it throws me an error saying : undefined alias 'result_1'. The macro i am using : define macro_result (source , metric_name , metric_value) returns result_metric { result_1= foreach $source generate timestamp, member_sk as id, '$metric_name' as minor_metric, 'Lts_seo' as major_metric, $metric_value as...

nasm, macro print not working

c,assembly,macros
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 of the elements pointed by them. Here is the C code: extern int...

error when vim macro recording play

vim,macros
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, [email protected] should be work, But for me, It...

Average in assembly 8086 (macro error)

assembly,macros,average,8086
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: 0711E byte 24h not found after 2000 bytes. ; correct example of INT...

How to write an ipython alias which executes in python instead of shell?

python,macros,ipython,alias,ipython-magic
We can define an alias in ipython with the %alias magic function, like this: >>> d NameError: name 'd' is not defined >>> %alias d date >>> d Fri May 15 00:12:20 AEST 2015 This escapes to the shell command date when you type d into ipython. But I want...

Correct way to cast a gpointer to a GType

types,macros,glib,gnome
I am trying to create a macro which will cast a gpointer to GType and vice versa. I have created the following macros to do this using the relevant API documentation as a guide: #ifdef GTYPE_TO_POINTER #define GTYPE_TO_POINTER (x) (GSIZE_TO_POINTER (x)) #endif #ifdef GPOINTER_TO_GTYPE #define GPOINTER_TO_GTYPE(p) (GPOINTER_TO_SIZE (p)) #endif I...

Why is it not advised to define macros in header files?

c++,macros,preprocessor
The Google C++ Style Guide guide advises that macros must not be defined in a .h (header) file. What are the cons of doing it?

Can I create a macro or shortuct for a step of XPath in XQuery?

xml,xpath,macros,xquery
Do we have Macros in XQuery? If yes, could you please give an example of their usage. I have the following code let $x := //price/ancestor::* Can I someway, using macros or other things write it as follows: let $x := //price/outward So, the outward should mean ancestor::*...

Dose VS2010 pre-calculate preprocessor defined by #define?

c++,visual-studio-2010,macros,preprocessor
For Visual Studio 2010, if I define #define PI 4.0f*atan(1.0f) when PI is used somewhere later in the code, does the value needs to be calculate again or simply 3.1415926... being plugged in? Thanks. EDIT: Because I heard someone says the compiler might optimize to replace it with 3.1415926.., depending...

How to implement a runtime debug assertion without macros in C++ 11/14 with type safety?

c++,c++11,macros,assertion
An assertion to be used in a context like: ASSERT(dynamic_cast<Derived*>(_ptr)); ptr = static_cast<Derived*>(ptr); So during debugging the assertion will check the dynamic cast but will be removed for the release mode. (standard assertion behaviour) How can I implement this using without macros. What I was thinking was: void ASSERT(bool _arg)...

Use Weka from ImageJ macro: 'path' is required but unset

macros,weka,imagej
I have tried Calling Weka from an ImageJ(Fiji) macro: run("Trainable Weka Segmentation", "open=C:\\input\\test.tif inputfile=C:\input\test.tif path=[Ljava.lang.String;@77e655d8"); But when I run that I get an error message: 'path' is required but unset This line is exactly the line I get when recording a macro and opening test.tif when the Trainable Weka Segmentation...

Is it safe to use macros in R?

r,macros
I have written some macros in R using the defmacro function from the gtools package: #' IfLen macro #' #' Check whether a object has non-zero length, and #' eval expression accordingly. #' #' @param df An object which can be passed to \code{length} #' @param body1 If \code{length(df)} is...

Statement in C++ macro

c++,c,macros,c-preprocessor
Reading chromium code, found helpful macro for handling EINTR errno of system calls on POSIX compliant systems. Here are the code(base/posix/eintr_wrapper.h): #define HANDLE_EINTR(x) ({ \ decltype(x) eintr_wrapper_result; \ do { \ eintr_wrapper_result = (x); \ } while (eintr_wrapper_result == -1 && errno == EINTR); \ eintr_wrapper_result; \ }) The question...

Importing Flat file dynamically using %MACRO and dataset values SAS

macros,sas
I have a folder with various flat files. There will be new files added every month and I need to import this raw data using an automated job. I have managed everything except for the final little piece. Here's my logic: 1) I Scan the folder and get all the...

Why use max and min macro in __global__ kernel of CUDA not giving correct answer?

c++,cuda,macros
I was trying to write a simple CUDA function to blur images. I use myself defined max and min macro as #define min(a, b) ((float)a > (float)b)? (float)b: (float)a #define max(a, b) ((float)a > (float)b)? (float)a: (float)b The part of __global__ kernel is: float norm; float sum = 0;// when...

Expand define macro with include macro

c++,c,macros,include
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....

Can I create a macro that unrolls loops?

macros,rust
I'm trying to write some fast matrix code in Rust and to do this needs to ensure that loops are unrolled. Is there a way to create a compile-time for-loop? E.g: I want unroll_loop!(f, a, 3); to generate f(a, 0); f(a, 1); f(a, 2); ...

Writing a `define-let` macro, with hygiene

macros,racket,define-syntax,hygiene
I'm trying to write a define-let macro in racket, which "saves" the header of a (let ((var value) ...) ...) , namely just the (var value) ... part, and allows re-using it later on. The code below works as expected: #lang racket ;; define-let allows saving the header part of...

Is that possible to get comments with macro?

macros,elixir
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?...

Get the ith word in a macro variable list

macros,sas
%let TableList = TableA TableH TableB TableG; Words in &TableList are separated by ' '. How can I retrieve certain word to do the following? I do not know the number of words in the tablelist and would like to get the nth word from the list. Given i =...

Split string in macro

c++,string,split,macros
I've a class name with its namespace, like BasicType::MyType. It's possible to create a macro that split the name and uses only the part after the scope operator (I want to create a MyType object in macro without the first part)? EDIT: I'm using a library with different classes in...

Unexpected output printf statement [duplicate]

c,macros,printf,ternary-operator
This question already has an answer here: Why is “i” variable getting incremented twice in my program? 8 answers Why outputs of i and j in the following two printf()s are different? #include <cstdio> #define MAX(x,y) (x)>(y)?(x):(y) int main() { int i=10,j=5,k=0; k==MAX(i++,++j); printf("%d %d %d\n",i,j,k); i=10,j=5,k=0; k=MAX(i++,++j); printf("%d...

Creating a function in compile time using a bitmap like macro

c,macros
I have an ansi C function to sum up values from an array, based on patterns. Something like: long sum_all_according_to_pattern(int n, int *values, int *pattern) { long sum = 0; int i = 0; for(;i<n;i++){ if(pattern[i]) sum+=values[i]; } return sum; } Let's say I've a set of patterns such as:...

Macro for defining trait aliases

macros,rust
According to this isuue issue and this answered question it is not possible to simply define a trait alias like: trait Alias = Foo + Bar; The workaround is a bit ugly: trait Alias : Foo + Bar {} impl<T: Foo + Bar> Alias for T {} Therefore I want...

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

visual-studio,visual-c++,visual-studio-2013,configuration,macros
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 Property Sheet will look something like this: The $(Configuration) Macro is the Name of...

Can macros expand to a combination of patterns?

macros,pattern-matching,rust
As of Rust 1.0, there is no way to group multiple patterns into one binding: // It does not compile match x as char { b @ ('A' | 'Z') => println!("A or Z: {}", b), _ => println!("Try again") } // Correct version match x as char { b...

C++: complex function-like macro definition

c++,node.js,macros
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 PER_ISOLATE_STRING_PROPERTIES(V) \ V(address_string, "address") \ V(args_string, "args") \ V(argv_string, "argv") \ V(async, "async") \ V(async_queue_string, "_asyncQueue") \ V(atime_string, "atime")...