stringification Questions
5
Solved
For example I have a macro:
#define PRINT(int) printf(#int "%d\n",int)
I'm somewhat aware of the outcome.
But how come #int represent the whole thing?
I'm somewhat forget this detail. Ca...
Endways asked 16/1, 2013 at 5:34
6
Solved
I would like to create a C pre-processor macro that will single-quote the argument. Just like the common used #X.
I want Q(A) to be expanded to 'A'.
I am using gcc on Linux.
Does any one have an...
Rappel asked 15/1, 2010 at 15:9
3
Solved
When using C preprocessor one can stringify macro argument like this:
#define TO_STRING(x) "a string with " #x
and so when used, the result is as follows:
TO_STRING(test) will expand to: "a str...
Electrical asked 8/8, 2011 at 12:33
7
Solved
Why doesn't this produce anything?
console.log(JSON.stringify(function(){console.log('foobar');}));
Remediosremedy asked 29/9, 2012 at 10:35
5
Solved
I have a preprocessor macro defined in build settings
FOO=BAR
That value I want to massage into an Objective-C string literal that can be passed to a method. The following #define does not work,...
Flickinger asked 30/9, 2011 at 4:8
6
Solved
I'm looking for a way to convert a preprocessor token to a string.
Specifically, I've somewhere got:
#define MAX_LEN 16
and I want to use it to prevent buffer overrun:
char val[MAX_LEN+1]; // ...
Unbacked asked 27/10, 2008 at 15:43
2
Solved
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.
...
Paradisiacal asked 22/2, 2019 at 6:32
2
Solved
I want to pass a version string in the compile command:
$ g++ -Wall -D VERSION="2013-12-03 02:15:21, commit cb060df" -o main main.cpp
Inside my code, I have the following:
#define TOSTR_(x) #x
...
Swindell asked 4/12, 2013 at 19:57
8
Is it possible in C++ to stringify template arguments?
I tried this:
#include <iostream>
#define STRINGIFY(x) #x
template <typename T>
struct Stringify
{
Stringify()
{
std::cout &l...
Scarab asked 28/9, 2009 at 17:4
2
Solved
What does the '#' symbol do after the second define? And isn't the second line enough? Why the first one?
#define MAKESTRING(n) STRING(n)
#define STRING(n) #n
Glary asked 26/1, 2018 at 15:18
3
Solved
How can I stringify a preprocessor macro with GNU gfortran? I would like to pass a macro definition to GNU gfortran which will then be used as a string in the code.
Effectively I would like to do ...
Magill asked 27/7, 2015 at 9:38
4
I'm trying to define a macro to generate a token name, containing a variable.
Basically, what I'm trying is this:
#define GLUER(x,y,z) x##y##z
#define PxDIR(x) GLUER(P,x,DIR)
int main() {
int p...
Archaic asked 3/9, 2010 at 4:22
2
Solved
I've seen this topic which describes the "stringify" operation by doing:
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#define MAJOR_VER 2
#define MINOR_VER 6
#define MY_FILE "/home/user/...
Krp asked 17/2, 2015 at 21:35
12
Solved
How do you convert a jQuery object into a string?
Guanine asked 17/3, 2009 at 1:38
3
Solved
#include <stdio.h>
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)
int main()
{
printf("%s\n",h(f(1,2)));
printf("%s\n",g(f(1,2)));
return 0;
}
Just by looking at the progr...
Ramentum asked 6/12, 2010 at 9:36
2
Solved
I'm using this preprocessor macro to "stringify" and return easily from a definition resolving function:
#define STRINGIFY_RETURN(x) case x: return #x ""
It works like a charm in MBSC environmen...
Lahomalahore asked 9/9, 2016 at 2:54
1
Solved
I would like to use an #include directive with a file name that is passed as an externally defined macro.
E.g.
#include #FILE".h"
where FILE would be defined as the string MyFile (without quot...
Dilute asked 27/10, 2015 at 8:7
3
Solved
I have a set of target macros for which I want to generate aliases based on a choosing macro, like so:
Choosing macro:
#define I2C_MODULE 1
Alias macros (conceptual form):
#define I2C_MO...
Colwin asked 13/3, 2015 at 14:10
2
Solved
We're using jstree for a navigation menu editor, and have been assigning metadata to the nodes of the tree like this:
var data = currentNode.data("jstree");
data.title = textBoxTitle.val();
data.l...
Arid asked 25/10, 2010 at 14:2
1
Solved
I have realised (the hard way) that operator eq gives a fatal runtime error when one of the operand is an object with overloaded stringification.
Here is a minimal example:
my $test = MyTest->...
Pterodactyl asked 1/5, 2014 at 11:51
3
Solved
I am working on a project where I have many constant strings formed by concatenation (numbers, etc.).
For example, I have a LOCATION macro that formats __FILE__ and __LINE__ into a string that I c...
Noll asked 3/2, 2010 at 14:4
2
Solved
Is it possible to stringify this C macro:
#define GPIO_INT_PIN (GPIO_PORT_D|GPIO_PIN_IRQ_RISING|GPIO_PIN5)
using something like
MY_STRINGFY(GPIO_INT_PIN)
to get
"(GPIO_PORT_D|GPIO_PIN_I...
Toughminded asked 23/1, 2014 at 13:42
3
Solved
I have been trying to implement a function macro in C that prepends "DEBUG: ", to the argument, and passes its arguments to printf:
#define DBG(format, ...) printf("DEBUG: " #format "\n", __VA_ARG...
Brunswick asked 23/9, 2013 at 20:18
1
Solved
The C and C++ standards all include text to the effect that if a stringize operation fails to produce a valid string literal token, the behavior is undefined. In C++11 this is actually possible, by...
Diploma asked 2/7, 2013 at 1:55
2
Solved
I know that:
#define foo 4
#define str(s) #s
with str(foo) writes out: "foo", because stringify is executed first of text expansion, but this:
#define xstr(s) str(s)
#define str(s) #s
#defi...
Squarely asked 7/6, 2013 at 17:25
1 Next >
© 2022 - 2024 — McMap. All rights reserved.