Questions tagged [macros]

1

votes
3

answer
58

Views

Advanced symbol-macrolet

Suppose I have a class class with slots first and second. Inside my function I can bind a variable to one of those slots like (symbol-macrolet ((var (first cls))) ....) Obviously I can also bind the second slot to smth. Questions is, let's say that first and second are either some number or nil. Le...
Andrew S.
2

votes
1

answer
31

Views

How to generate a pre-proccessor definition using a macro?

I want to dynamically create pre-proccessor literal strings where part of the string is created by some arithmetic, for example: math(x) x - 0x1234. The generated definitions would be made by the macro:get_tex_uniform_name(unit), and the results would be the same values as the following numerically...
ichster
1

votes
1

answer
50

Views

Is there an elegant way in Scala to define an asynchronous API based on a synchronous one?

I suspect the answer is NO, but thought I would ask anyway. Given something like trait foo { def sum(a: Int, b: Int): Int } Is there some Scala magic I can do to produce, or implicitly define trait fooAsync { def sum(a: Int, b: Int): Future[Int] } or do I just have to brute force it, and define fooA...
Eric Kolotyluk
1

votes
1

answer
52

Views

Using macro with variables in c

I have a flat C file including ctype.h where i cant figure out how a macro works. There is this macro #define da_dim(name, type) type *name = NULL; \ int _qy_ ## name ## _p = 0; \ int _qy_ ## name ## _max = 0 I thought it should define the type of a given value. So for example i could wri...
DoJo
1

votes
2

answer
60

Views

Define a function which function name is masked by a macro

Sometimes, it can be handy to mask a function by a macro of same name. In this contrived example, the macros makes it possible to insert additional verification while calling function(). int function(int i); #define function(i) ( assert(i>0), function(i) ) Other more common usages make the macro tr...
Cyan
1

votes
1

answer
43

Views

Constant value of __TIME__ in whole program [duplicate]

This question already has an answer here: C++ __TIME__ is different when called from different files 3 answers If I have a C program consisting of multiple C source files that each use the preprocessor directives __DATE__ and __TIME__, is there any way I can make sure that the value is always the s...
Florian Bach
1

votes
4

answer
72

Views

What happens if I redefine a macro in C without undef directive [duplicate]

This question already has an answer here: #define many times without #undef,is it legal? 4 answers What happens when a C preprocessor macro is defined twice? 3 answers I want to know the severity of the warning that my compiler is throwing for the 'macro MACRO_NAME redefined'. It is redefined...
1

votes
2

answer
97

Views

How can I macro #define a static method call in C++?

I am trying to write software that can behave differently based on whether or not a certain component should be simulated in software or execute on real hardware. However, GCC complains that the Scope resolution operator (::) cannot be used in a macro, so my question is: is it possible to define a m...
xyzhou
1

votes
1

answer
108

Views

How to check Clojure, macro specs?

If I try to check a macro spec with clojure.spec.test.alpha, no tests are run, but if I define the same macro as a function with the same spec, a sequence of tests are run against the function. I can always generate parameters to unit test the macro, but is there a way to get that for free with spe...
Dylon
1

votes
1

answer
56

Views

How to print the name of a recursive lambda template?

For debug purpose, would it be possible to use any macro to print the name of a recursively defined lambda inside a class template function? For example template class X{ public: X(); //rest of declaration private: //rest of declaration }; template X::X(){ functionsomeLambda = [] (){ //recursive d...
user9196120
1

votes
0

answer
189

Views

How to use variadic macro arguments in both a function definition and a function call?

I'm trying to use a macro to define several similar functions based on the macro's parameters. However the number and types of parameters that the resulting function needs to take isn't the same across all of the functions, but I also need to pass all of the function's arguments into another variadi...
AJMansfield
1

votes
1

answer
257

Views

Scala macros: generate code based on file contents

I would like to generate scala classes based on some files. Placement of the files doesn't matter (it can be resources folder or files can be placed just near my scala source files). How can I read them when scala macro is executed? (I use StaticAnnotation's inline def apply(defn: Any): Any method)...
Evgeny Nacu
0

votes
1

answer
46

Views

Define macros with condition in C++

I found some existing answer on SO, but I actually don't understand how does everything there works. Basically, I want to define a macro in if/switch condition if (condition) { #define SOME_MACRO } So, if some condition is true, there will be defined some new macro. But, as for now, it just defines...
StupiStupiDu
1

votes
2

answer
39

Views

vbscript macros shortening lines of code

so like in C++ where you can turn lines into one word (macro, yes?), is there a way to do this in vbscript? e.g. instead of Set shell = WScript.CreateObject('WScript.Shell') Set sh = WScript.CreateObject('WScript.Shell').Exec('Firefox') Can I shorten to something like Set shell = MACRO.Exec('Firefo...
NerdyKid1101
1

votes
0

answer
137

Views

Can I append a variable name to the setter and getter function names in a macro? [duplicate]

This question already has an answer here: How to prefix/suffix identifiers within a macro? [duplicate] 3 answers Can a Rust macro create new identifiers? 2 answers Is it possible to declare variables procedurally using Rust macros? 2 answers I need to generate setters and getters for my FFI code....
KDN
1

votes
1

answer
338

Views

Call a Macro in to another macro sas

I want call a macro in to another macro, this creates a Macro variable which I want used in the other macro. But the output is 'WARNING: Apparent symbolic reference TEST33 not resolved.' data Base1; input v1 v2 v3; datalines; 1 7 8 ; run; %let number = 6; %Macro test1; proc sql noprint; select c...
Sandra Guerrero
1

votes
2

answer
72

Views

Check existence of an entry in C pre-processor list

Is it possible to check for the existence of an entry in a list defined by X-macro? Given the example code below, I'd like the #if defined(GEORGE) condition to be true. EDIT: without doing an explicit #define GEORGE, of course. I am hoping to have a way to check an entry in the list (in the pre-pr...
Tim
1

votes
1

answer
148

Views

How to stop an execution of a VIM macro in Idea Vim

I have the following problem: while experimenting with vim macros in Pycharm (I'm using Idea Vim plugin) - I typed a simple macro and make an editor to run it 100 times. The execution is extremely slow and I couldn't stop it using any of these pieces of advice. Has anyone had a similar problem and k...
Marcin Możejko
1

votes
0

answer
74

Views

nested macros in C _generic macro

I'm currently making a small SIMD vector/matrix library in C. I'm looking to use the _generic macro feature in C11 to make function calls always take vector(__m128) arguments as pointers. Is there any way to have the _generic macro call another macro if a non-pointer argument is given and then have...
shotgunbilly
1

votes
0

answer
155

Views

C++ ignoring warnings in a block with macro

I am using gcc 6.2 and want to ignore warnings in a macro. My idea was to do as in the following demo code. typedef char aligned_char __attribute__((__aligned__)); // disable warning using #pragma at the beginning of the macro // and enable it back at the end #define DISABLE_WARNING() \ _Pragma...
MGH
1

votes
0

answer
409

Views

CATIA macro from python

I would like to use my macro (.CATScript) to open the catia interface and make the changes listed in the macro script to the .CATpart and give output as .stp file. Is it possible to use python to realise this function? There was an example in Run a Catia macro with a python script, but it didn't wo...
Simulationeng_sam
1

votes
0

answer
309

Views

Automatically scroll down browser and click button, on a loop (Chrome)

I've never used browser macros, before I dive deeper into some rabbit hole I'm wondering if there's an easy way in Chrome to write a script that will: scroll down to the bottom of a page, click a 'Load More' button, wait 10s and then scroll down to the bottom of the page, and click the Load More but...
Antoine
1

votes
0

answer
37

Views

Resolving Nested macro linking error

I am getting a linking error because a function is declared in a .h file but its definition is commented. Below is the linking error: --- Linking Error --- Error: L6218E: Undefined symbol clk_SetHMSSAPMFreqPlan (referred from VVDRV_clk_glue.o). Now, the file where the function is being called has...
user3565150
1

votes
1

answer
184

Views

How does the new (probably in 4.17) linux kernel max macro work?

This lwn article describes the new implementation of the max macro in the linux kernel: https://lwn.net/Articles/750306/#Comments The macro has been changed to evaluate to a constant expression if it is used with constant expressions. The problem was that -Wvla triggers if an array length is not a c...
not-a-user
1

votes
1

answer
139

Views

Creating mixed recursive macro to create a HTML templating DSL

I'm new to Rust and even more to the macro engine, I'm trying to come up with a way of creating a DSL that I'll use for HTML templating that looks like the following, h! { foo( 'bar', tag_with_parens(), tag_without_parens, 'some other expression', element(child), ), 'tags and strings can be sibling...
olanod
1

votes
0

answer
56

Views

Create a Msg box in Notepad++ Macros

I have a macro that finds 's and replaces few strings. Below is the code. What I want Notepad++ to do is to show a message box if it doesn't find the string '_last'. How to achieve this? PS: I have found a very old post where it says that an older version of notepad++ shows a pop-up window on each...
Gangula
1

votes
1

answer
21

Views

SAS distinct level

data test1; input var1$ var2$ ; datalines; 1 a 2 a 3 a 1 b 2 b 1 c ; run; How can I create a macro var that contains all levels of var2? For example: %Let new_var = a b c;
user1481397
1

votes
1

answer
90

Views

Using macros that define version numbers in the form 10.0.0

I compile one of my C codes with a Mathematica C header file. Mathematica uses a macro to tell you which version you are using. The format is #define WSMATHVERSION 10.0.0 I'm more familiar with this pattern of version numbering in macros, // BOOST_VERSION % 100 is the patch level // BOOST_VERSION...
innisfree
1

votes
1

answer
53

Views

scala.meta.Lit.type does not take parameters

When I run the following: import scala.meta._ class Test { val x = q'1' } I get scala.meta.Lit.type does not take parameters val x = q'1' scalameta_2.11:1.8.0 paradise_2.11.8:3.0.0-M7 I'm trying to get some basic macro examples working, specifically the 'Hello' example found here: https://www.beyon...
user2682459
1

votes
0

answer
29

Views

How can I record a drive's volume label at compile time?

At first, I thought I could just use the __FILE__ macro but it only gives me the drive letter and path of the current file, what I need is something that includes the volume label. I know I can get the volume label using the GetVolumeInformation function but I really need the volume label of a driv...
1

votes
0

answer
28

Views

Single Stepping with Google Sheets Debugger

I have watched a few videos and read as many web pages about how to debug my Google Sheets Macro. Oddly, I can't get this ridiculously simple macro to work. It just takes the values in column A and sorts them to send duplicate values to the end. When I try to debug the macro using step into, the ste...
Dennis Kane
1

votes
1

answer
82

Views

How to use Google app script to automatically border line below When Value Changes

I want to add a border line below the row whenever column C value changes. I haven’t touched macro for a long time, this is a script I put together but it doesn’t work as expected. Anyone know where the problem is? Thanks! function underline() { var spreadsheet = SpreadsheetApp.getActive(); var...
santoku
1

votes
0

answer
167

Views

Cython macro definition in structure

I'm using Cython to import a structure to python from C while there are some macro definitions which include functions. I just don't how to realize the structure in Cython. typedef struct _SparMat { int m, n; int *rvec; int *ridx; double *rval; int *cvec; int *cidx;...
Icy
1

votes
1

answer
32

Views

Does visual studio has compilation mode with multiple drop down boxes?

I’m working with VisualStudio on a C++ project. I have multiple solution configurations in my project. Each one has a different MACRO definition. ConfigurationA: define A ConfigurationB: define B ConfigurationC: define C Now I need a different orthogonal set of configurations with MACRO definitio...
bochaltura
1

votes
0

answer
30

Views

Scala 2.11 refined with scalatest MustMatchers and Await causes compiler error “trying to do lub/glb of typevar ?F[?T, ?B]”

I have been trying to use the refined with scalatest and am getting compiler errors at the 'typer' phase: trying to do lub/glb of typevar ?F[?T, ?B] This is my best attempt at a minimalist reproduction of the issue using a self-contained ammonite script: import $ivy.`eu.timepit::refined:0.9.0` impor...
rmin
1

votes
2

answer
743

Views

Add a variable (column) in data set (SAS)

I can't find the solution for this simple problem: I want to add a colum/variable in my data set. This variable will always have the same value, stored in the macro variable &value. And I am in a macro so I don't know if it change anything... This is the step before merging 2 data step. So far, here...
videorama17
1

votes
2

answer
165

Views

how to get method body tree in scala macros

I am trying to convert scala object to js object object SObject { def foo(in:String):String = s'scalajs-$in' } val o = ScalaObjectToJSObjectMacro(SObject) // js.Dynamical.literal(foo = (in:String) => s'scalajs-$in') in macro i am able to get all Methods of object(in.tpe.decls.toList) and then for...
invariant
1

votes
0

answer
191

Views

Passing an array to macros in Twig

I am trying to use twig macros to create re-usable snippets on html code that I insert back into my main template however I'm running into an issue when attempting to pass an array to my macro: Macro call: {{ wrapper.outputConclusionList(viewData['response']['Report']['ContactBullets']) }} Macro fun...
Alex R
1

votes
2

answer
68

Views

Saving significance of a regression

I am running several simple regressions and I wish to save the value of the significance (P > |t|) of a regression for a given coefficient in a local macro. For example, I know that: local consCoeff = _b[_cons] will save the coefficient for the constant, and that with _se[_cons] I can get the standa...
1

votes
1

answer
690

Views

Overwriting Google sheets (for form response) rows if duplicate entered

So, I've been trying to figure out how to stop the duplicate rows appearing in my google sheets response output from a google form. If found this link which sounds like it does exactly what I want (Form Google Script Prevent Duplicates), but cannot for the life of me work out how to edit the given a...
Smashing

View additional questions