macros

Conditional formatting over huge range in excel, using VBA

非 Y 不嫁゛ 提交于 2020-07-09 12:38:06
问题 I have an excel workbook that has about 30k rows in a given column. I need to cross validate another equally huge list to see if there are any matches. If so, then I want it to highlight that cell. As suggested in other threads, I recorded the macro manually and the code is: Sheets("Main").Select Columns("D:D").Select Selection.FormatConditions.Add Type:=xlTextString, String:= _ "=list1!$A$1", TextOperator:=xlContains Selection.FormatConditions(Selection.FormatConditions.Count)

Inverse currying for macros?

自作多情 提交于 2020-07-08 12:59:50
问题 Assume we have a #define FOO(x,y) something . I want to construct such macro #define BAR that BAR(x)(y) would call FOO(x,y) . How can I do it, if it's possible at all? I tried following: #define BAR(x) FOO(x, BAR_ #define BAR_(y) y) But got: error: unterminated argument list invoking macro "FOO" Here's a MCVE: #include <iostream> #define FOO(x,y) std::cout << x << y << '\n'; #define BAR(x) FOO(x, BAR0 #define BAR0(y) y) #define STR(...) STR0(__VA_ARGS__) #define STR0(...) #__VA_ARGS__ int

Can someone explain the concept of 'hygiene' to me (I'm a scheme programmer)?

若如初见. 提交于 2020-07-04 20:15:33
问题 So... I'm new to scheme r6rs, and am learning macros. Can somebody explain to me what is meant by 'hygiene'? Thanks in advance. 回答1: Hygiene is often used in the context of macros. A hygienic macro doesn't use variable names that can risk interfering with the code under expansion. Here is an example. Let's say we want to define the or special form with a macro. Intuitively, (or a b c ... d) would expand to something like (let ((tmp a)) (if tmp a (or b c ... d))) . (I am omitting the empty (or

WRITE_ONCE in linux kernel lists

こ雲淡風輕ζ 提交于 2020-07-04 05:42:29
问题 I am reading the linux kernel implementation of doubled linked list. I do not understand the use of the macro WRITE_ONCE(x, val) . It is defined as follow in compiler.h: #define WRITE_ONCE(x, val) x=(val) It is used seven times in the file, such as static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { next->prev = new; new->next = next; new->prev = prev; WRITE_ONCE(prev->next, new); } I have read that it is used for avoiding race conditions. I

WRITE_ONCE in linux kernel lists

折月煮酒 提交于 2020-07-04 05:42:09
问题 I am reading the linux kernel implementation of doubled linked list. I do not understand the use of the macro WRITE_ONCE(x, val) . It is defined as follow in compiler.h: #define WRITE_ONCE(x, val) x=(val) It is used seven times in the file, such as static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { next->prev = new; new->next = next; new->prev = prev; WRITE_ONCE(prev->next, new); } I have read that it is used for avoiding race conditions. I

WRITE_ONCE in linux kernel lists

北战南征 提交于 2020-07-04 05:41:41
问题 I am reading the linux kernel implementation of doubled linked list. I do not understand the use of the macro WRITE_ONCE(x, val) . It is defined as follow in compiler.h: #define WRITE_ONCE(x, val) x=(val) It is used seven times in the file, such as static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { next->prev = new; new->next = next; new->prev = prev; WRITE_ONCE(prev->next, new); } I have read that it is used for avoiding race conditions. I

Macro annotation to override toString of Scala function

假如想象 提交于 2020-07-04 01:54:33
问题 How to write macro annotation which looks in usage like @named("+2") _ + 2 and produces: new (Int => Int) { override def toString(): String = "+2" def apply(x: Int): Int = x + 2 } 回答1: Correct syntax is ((_: Int) + 2): @named("+2") . Unfortunately macro annotations annotating expressions don't expand. The simplest is to use object Named { def build[T, R](name: String)(applyFunc: T => R): T => R = new (T => R) { override def toString() = name def apply(x: T): R = applyFunc(x) } } without any

C preprocessor tokenization does not expand macro?

对着背影说爱祢 提交于 2020-07-02 18:05:26
问题 1) Why is the macro MSG not expanded in the following expression? #define MSG Hello #define HELLO(name) MSG ## name void HELLO(Dave) () {} Using gcc -E -P test.cpp Output: void MSGDave () {} MSG name expands to Hello Dave . And MSG # name expands to Hello "Dave" . So what causes gcc not to expand MSG ## name ? 2) Is there a workaround? Is there a preprocessor directive like defined(x), such as expand(x)? 回答1: #define MSG Hello #define cat(x, y) x ## y #define cat2(x, y) cat(x, y) #define

Password button and userform

纵然是瞬间 提交于 2020-06-26 16:54:09
问题 I have programmed the following userform in Excel VBA: Private Sub CommandButton1_Click() Password = TextBox1.Text If Password = a Then MsgBox "Password Correct.", vbInformation Unload Me Else MsgBox "Password Incorrect. Please try again.", vbCritical End If End Sub The password variable a = "test" This password userform itself works perfectly. Now I want to connect it to a button that is already in the sheet. The code behind this button is in the section "ThisWorkbook" in the VBA editor: Sub

Replace a string in a macro variable?

雨燕双飞 提交于 2020-06-26 13:51:26
问题 I have a macro where I pass in an argument and use that define a new variable based on the name of the input: #define DO_X(x) char _do_x_var_ ## x; /* other things */ The problem is if I pass in a struct variable, it breaks: DO_X(some_struct->thing) becomes: char _do_x_var_some_struct->thing; /* other things */ EDIT: What I want it to evaluate to is: char _do_x_var_some_struct__thing; /* other things */ (or any valid variable name containing something similar to the input) What I actually