Questions tagged [stringification]

Stringification refers to the use of the `#` operator in a **C** preprocessor macro to use an argument as a string. Similarly the preprocessor operator `##` can be used to concatenate two arguments, and this tag can also be used.

Stringification refers to the use of the # operator in a C preprocessor macro to use an argument as a string constant. Similarly the preprocessor operator ## can be used to concatenate two arguments, and this tag can also be used.

For full details consult the manual pages:

Related Tags

174 questions
0
votes
3 answers

C/C++ preprocessor single quote?

Possible Duplicate: How to single-quote an argument in a macro? How can it do the following: #define MACRO(X) ... MACRO(a) // should give 'a'
Anycorn
  • 50,217
  • 42
  • 167
  • 261
0
votes
0 answers

Macro to stringify the result of an arithmetic expression

Is it possible to write a preprocessor macro which stringifies the result of an integer arithmetic expression in clang? For example: #define WIDTH 20 #define HEIGHT 30 int main() { puts("The total area is " INT_TO_STRING(WIDTH*HEIGHT)); } I…
Vladimir Panteleev
  • 24,651
  • 6
  • 70
  • 114
0
votes
1 answer

C++ namespace as a macro value

I have simple delegate functions in my C++ test code. Since I cannot include the original implementation .cpp files(embedded ones), I use delegate .cpp file in the tests that are running on PC. My idea is to simply use the same macro as a body for…
arapEST
  • 491
  • 1
  • 4
  • 16
0
votes
2 answers

Changing Host side code for openCL C++ after stringifying the kernel code

I am working on a project where I am using openCL C++ bindings. I have a kernel.cl file that is read from the host side and loaded and executed. But now I want to embed it into my .cpp file so I can distribute the binary file without the kernel.cl…
Mohammad Sohaib
  • 577
  • 3
  • 11
  • 28
0
votes
0 answers

c# Generic way to stringify arrays of structs

I've searched for quite some time, but I have not been able to find how to generically stringify an array of structures in C# at runtime. Let's say I have public enum FieldInfoType { FitUInt32, FitStruct, FitUint32Array1D, …
Paul Grinberg
  • 1,184
  • 14
  • 37
0
votes
1 answer

Stringize loopcounter to reference members of C struct

I have two structs that appears like: typedef unsigned char byte; struct my_struct_2 { int type; int length; //will be 2 in this case byte value1; //MSB byte value2; //LSB } struct my_struct_4 { int type; int length; //will be 4 in this case byte…
Ryan
  • 33
  • 1
  • 6
0
votes
1 answer

Stringify Endpoint for Xcode LLVM Processor Macros

In the "Apple LLVM 7.0 - Preprocessing" section under the "Build Settings" tab, I've defined a Preprocessor Macros…
Vee
  • 1,821
  • 3
  • 36
  • 60
0
votes
3 answers

save expanded macro result before it is undefined

With GCC, I am using X-macros for a collection of variables. #define TEST_MAP \ X(0, 1, 2) \ X(0, 2, 2) \ X(0, 3, 5) Let's suppose I need to sum up all the 2nd fields #define X(a,b,c) (+b) /* sum all 2nd elements of…
Vitomakes
  • 315
  • 4
  • 12
0
votes
3 answers

How to create a string from a pre-processor macro with arguments

I'm trying to stringify a macro in System Verilog, so I can use it in a string for printing. I created a STRINGIFY macro: `define STRINGIFY(x) `"x`" as suggested here: How to create a string from a pre-processor macro However, the macro I'm trying…
Zamfir Yonchev
  • 151
  • 1
  • 10
0
votes
3 answers

Struct initialisation through macro overuse

I've got some structs to initialise, which would be tedious to do manually. I'd like to create a macro that will help me with it... but I'm not sure the C preprocessor is good enough for this. I've got structs which represent menus. They consist of…
viraptor
  • 33,322
  • 10
  • 107
  • 191
0
votes
1 answer

Postgres 9.2 select star into an array

I want to do something like this inside a stored procedure so I can see the result of an insert statement for debugging: thing := array_to_string(ARRAY(select * from some_table limit 1 )); raise info 'insert result: %',thing; Where all the columns…
slashdottir
  • 7,835
  • 7
  • 55
  • 71
0
votes
2 answers

GCC Preprocessor for inline method name

I'm working on a project where I have code like the following: #define NAME() Array inline NAME()* NAME()_init (void* arg0){return (NAME()*)Object_init(arg0);} But I get the following result: inline Array* Array _init (void* arg0){return…
Maz
  • 3,375
  • 1
  • 22
  • 27
0
votes
1 answer

Asterisk in the argument name with C preprocessor

I want to implement cross-platform build of my DLL with mingw32/VC. At the moment everything is perfect with mingw side. However I have to wrap several things in macro for VC (it is built as /TC), for example: void __attribute__((fastcall)) do1 ( …
pugnator
  • 665
  • 10
  • 27
0
votes
1 answer

How to convert an unsigned define variable in an signed define variable in C

#define VERSION 1U #define _VALUE_TO_STRING(x) #x #define VALUE_TO_STRING(var) _VALUE_TO_STRING(var) #define VERSION_STRING VALUE_TO_STRING(VERSION) char readMe[] = "The current version of this document is " VERSION_STRING "."; ... I have this…
0
votes
1 answer

What happens when the preprocessor sees SLOT(a) "1"#a

My understanding is the preprocessor #define replaces identifier with replacement #define Let's suppose we have the following: #define SLOT(a) "1"#a void myValue(int value); SLOT(myValue(int)); I understand that # means…
user2836797
1 2 3
11
12