macros

SAS Loop through list of macro variable

天涯浪子 提交于 2021-02-10 07:14:37
问题 First off, I'm new so I apologize if this is not a good question. I searched but did not find something similar. I'm not sure my approach is correct so any assistance would be appreciated. I'm working on a data set for a school that has semesters for example 2017SP is Spring of 2017, 2017SU is Summer of 2017 and so on. I have the following program where I set up a Macro Variable at the top and then use it to pull out the term from various libraries and data sets. Note that I have several data

SAS Loop through list of macro variable

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 07:12:56
问题 First off, I'm new so I apologize if this is not a good question. I searched but did not find something similar. I'm not sure my approach is correct so any assistance would be appreciated. I'm working on a data set for a school that has semesters for example 2017SP is Spring of 2017, 2017SU is Summer of 2017 and so on. I have the following program where I set up a Macro Variable at the top and then use it to pull out the term from various libraries and data sets. Note that I have several data

How can a macro define a valid global name based on the type passed to it?

守給你的承諾、 提交于 2021-02-10 04:36:05
问题 I believe the title is self-explanatory, but here's an example to illustrate what I'm trying to accomplish: #define PASTE2(_0, _1) _0 ## _1 #define DEFINE_OPS_FOR_TYPE(TYPE) \ int PASTE2(do_something_with_, TYPE)(void) { \ /* do_something_with_<TYPE> */ \ } Everything works fine for char , int , and single-worded types, but when it comes to unsigned types, or others that have multiple keywords, using token pasting ( a ## b ) does not generate a valid name due to the whitespace (e.g.: do

Julia: inject code into function

浪子不回头ぞ 提交于 2021-02-10 04:28:33
问题 I would like to inject code into a function. For concreteness, consider a simple simulater: function simulation(A, x) for t in 1:1000 z = randn(3) x = A*x + z end end Sometimes I would like to record the values of x every ten time-steps, sometimes the values of z every 20 time-steps, and sometimes I don't want to record any values. I could, of course, put some flags as arguments to the function, and have some if-else statements. But I would like to rather keep the simulation code clean, and

Julia: inject code into function

岁酱吖の 提交于 2021-02-10 04:28:27
问题 I would like to inject code into a function. For concreteness, consider a simple simulater: function simulation(A, x) for t in 1:1000 z = randn(3) x = A*x + z end end Sometimes I would like to record the values of x every ten time-steps, sometimes the values of z every 20 time-steps, and sometimes I don't want to record any values. I could, of course, put some flags as arguments to the function, and have some if-else statements. But I would like to rather keep the simulation code clean, and

C macro get typeof argument

▼魔方 西西 提交于 2021-02-08 17:01:01
问题 I am trying to write a macro to assist with object oriented programming in C. As I store the class information in a constant struct, I need to create a macro that does the following: Take the type of the object (typeof the derefenced pointer) Append _info to get the name of the desired classInfo struct Take the address of that symbol so it can be passed to the function Call the destroyObject function with a pointer to the class struct and the object itself An example: queue_t* p = NULL;

Documenting a function created with a macro in Rust [duplicate]

吃可爱长大的小学妹 提交于 2021-02-08 15:14:30
问题 This question already has an answer here : Generating documentation in macros (1 answer) Closed 4 years ago . I tried to do #![deny(missing_docs)] in Rust. And I found that /// comments are just ignored when a function is created with a macro like this: /// docs py_module_initializer!(libx, initlibx PyInit_libx |py, m| { Ok(()) }); with: error: missing documentation for a function 113 | py_module_initializer!(libx initlibx PyInit_libx |py, m| { | ^ I thought a macro will just add a function

Documenting a function created with a macro in Rust [duplicate]

我怕爱的太早我们不能终老 提交于 2021-02-08 15:13:38
问题 This question already has an answer here : Generating documentation in macros (1 answer) Closed 4 years ago . I tried to do #![deny(missing_docs)] in Rust. And I found that /// comments are just ignored when a function is created with a macro like this: /// docs py_module_initializer!(libx, initlibx PyInit_libx |py, m| { Ok(()) }); with: error: missing documentation for a function 113 | py_module_initializer!(libx initlibx PyInit_libx |py, m| { | ^ I thought a macro will just add a function

How to switch and case for string?

左心房为你撑大大i 提交于 2021-02-08 10:14:01
问题 I have the following code #define SWITCH(S) char *_S = S; if (0) #define CASE(S) } else if (strcmp(_S, S) == 0) {switch(1) { case 1 #define BREAK } #define DEFAULT } else {switch(1) { case 1 int main() { char buf[256]; printf("\nString - Enter your string: "); scanf ("%s", buf); SWITCH (buf) { CASE ("abcdef"): printf ("B1!\n"); BREAK; CASE ("ghijkl"): printf ("C1!\n"); BREAK; DEFAULT: printf ("D1!\n"); BREAK; } } If I generate the pre-processor code with gcc -E , I will get the following code

VBA code to open all excel files in a folder

三世轮回 提交于 2021-02-08 08:44:20
问题 I was working with a vba and I'm trying to open all excel files in a folder (about 8-10) based on cell values. I was wondering if this is the right approach to opening it, it keeps giving me syntax error where I wrote the directory. and when I rewrote that section, the vba only shot out the msgbox which meant it had to have looped and did something right? but didn't open any files. Any information will help. Thank you guys so much for taking the time to help me in any way. Sub OpenFiles() Dim