Timeline for What must a C macro do to be a valid answer?
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 27, 2017 at 9:33 | comment | added | l4m2 |
I also define macro that convert variable to pointer, to simplify some program(e.g. rewrite a realloc int rerealloc(void*&ptr, size_t len) , in a layer of macro)
|
|
Dec 23, 2017 at 11:14 | comment | added | user202729 |
Even in that case, a ? x : y is a completely valid lvalue in C++. There is no language restriction that can force the input to be atomic.
|
|
Dec 22, 2017 at 13:40 | comment | added | Peter Taylor | @l4m2, in the context of this answer that looks like an argument that macros should support passing by value or reference, but I suspect that may not be your intention. | |
Dec 21, 2017 at 22:05 | comment | added | l4m2 | Go back to function, I think int f(int&n) in C++ should be allowed, though it can't handle situations that input is a const or an expr | |
Dec 21, 2017 at 12:37 | comment | added | Peter Taylor | I'm not sure how many existing answers there are, but I don't see this as saying anything new but merely restating existing policy, and I don't think that being older than this answer should exempt existing answers from following policy which predated them. | |
Dec 21, 2017 at 12:24 | comment | added | user202729 | Another issue: What should be done with existing answers? That may be a different question, however. I think just keep it, but enforce this rule with newer answers. | |
Dec 21, 2017 at 11:47 | comment | added | Peter Taylor | Ah, that makes sense. I'll delete my comment on the question. | |
Dec 21, 2017 at 11:28 | comment | added | user202729 |
About "The argument must be referenced exactly once", it's so that the macro would be exactly equivalent to its functional counterpart, in case the argument has side effect, e.g. f(++i) or f(i++) .
|
|
Dec 21, 2017 at 9:44 | history | answered | Peter Taylor | CC BY-SA 3.0 |