177 questions
9
votes
1
answer
186
views
Does std::to_chars ever really disambiguate using round_to_nearest?
[charconv.to.chars] says the following:
The functions that take a floating-point value but not a precision parameter ensure that the string representation consists of the smallest number of ...
0
votes
2
answers
43
views
I need this file to stringify a book, a chapter, and a verse but it stringifies multiple books at once
This file splits the text variable from book, chapter, and verses. It should ideally look like this:
[
{
"book": "PLACEHOLDER",
"chapters": [
{
&...
1
vote
0
answers
58
views
C preprocessor: stringizing multiple levels of function-like macros
I'm working with multiple levels of macros where I rely on stringification of the parameters. My own functions have quite a few parameters already and stringizing them effectively doubles the number ...
1
vote
0
answers
50
views
Incorporate constant into byte array as ASCII correct code
I have some numeric constants in my data definition and would like to be able to use them inside my strings without having to embed them at runtime. Is this possible in MASM?
.data
LOWER_BOUND = 50
...
0
votes
1
answer
186
views
Use concatenation and stringizing in the same macro with GCC
Those macros are compiled without error with visual studio and codewarrior compilers. With gcc the error is shown in the comment
#define STRINGIFY(x) #x
#define MYINC(n) STRINGIFY(extensions/##n#...
1
vote
2
answers
402
views
Why can't GCC's typeof() be stringified?
I'd like to print the type that typeof() outputs, but typeid is only available in C++. Why can't I use stringification to get the name of this type?
#define GET_STRING(s) #s
#define example(input) ...
0
votes
1
answer
66
views
How to merge 2 serializable functions into 1 serializable function in JS?
As you know, there are certain cases (e.g., use in workers) when functions need to be serializable (and, at the other side, deserializable of course). I have such a case; a library function (i.e. I ...
2
votes
1
answer
779
views
How to contain escape sequences in macro definition #?
I am trying to use this macro definition in C:
#define STR(x) #x
Is it possible to contain some escape sequences inside x? e.g., I want to define a string like:
char* str = "\'";
This ...
0
votes
1
answer
212
views
Stringify a template numeric argument
I have the following piece of code:
template<int maxRegNum> void f(MuliInstr instr);
template<> void f<0>(MuliInstr instr)
{
if (instr.regA == 0) asm volatile ("mov r4, r0&...
0
votes
1
answer
60
views
How to access structure member with stringification (using ## or # in C macro)?
typedef enum
{
ENUM1_A=0,
ENUM1_B,
}someEnum1_e;
typedef union
{
someEnum1_e value;
}someEnum1_e_t;
#define GET_ELEMENT(data_name) blah.#data_name
int main (void)
{
someEnum1_e_t ...
2
votes
2
answers
613
views
C Preprocessor stringification (again) [duplicate]
Is it possible to have stringification after numeric evaluation?
This is better explained with a simple example:
#define A 1
#define B 2
#define SUM (A + B)
#define STR_IMPL_(x) #x
#define STR(x) ...
4
votes
3
answers
3k
views
`JSON.stringify` omits custom keys in array
I am storing my array as a mixture of array an array and an object. For example assume this one:
let arrObj = [];
arrObj["x"] = 12;
arrObj.push(12);
arrObj["y"] = 15;
arrObj.push(15);
// result: ...
6
votes
2
answers
157
views
What does Any.match do?
It has the deceivingly simple code:
method match(Any:U: |) { self.Str; nqp::getlexcaller('$/') = Nil }
However, this is the behavior it has:
(^3).match(1) # OUTPUT: «「1」»
So far, so good.
say (1,...
1
vote
1
answer
556
views
How to stringify char buffer for C macro
I have a LOG(fmt, ...) macro that does not work when using a char buf[] as fmt.
The code below is a complete (not actually) working example of the code. In some_function(), I am trying to use LOG() ...
-1
votes
1
answer
59
views
Accessing and modifying variables using token concatenation in C
I've been reading about stringification and token pasting and I was trying to access a variable using token pasting and modifying it's value. Is such a thing possible?
Suppose variables a0 and a1 are ...