Graphviz 13.0.0~dev.20250608.0154
Loading...
Searching...
No Matches
itos.h File Reference
#include <stdio.h>
Include dependency graph for itos.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  itos_
 return type of itos_ More...
 

Macros

#define ITOS(i)   (itos_(i).str)
 

Functions

static struct itos_ itos_ (long long i)
 

Macro Definition Documentation

◆ ITOS

#define ITOS (   i)    (itos_(i).str)

convert a signed number to a string

The string returned by this macro has a lifetime that (under ≥C11 semantics) only lasts until the end of the containing full expression. Thus intended usage is something like:

void foo(char *); foo(ITOS(42));

In particular, it is incorrect to store the result of this macro anywhere:

char *p = ITOS(42); // ← WRONG // p is now a dangling pointer, pointing to deallocated stack memory

You can think of ITOS as a C equivalent of the C++ std::to_string(i).c_str().

Parameters
iNumber to convert
Returns
Stringized conversion of the number

Definition at line 43 of file itos.h.

Function Documentation

◆ itos_()

static struct itos_ itos_ ( long long  i)
inlinestatic

convert a signed number to a string

This is not expected to be used directly. Callers are expected to use the ITOS macro instead.

Parameters
iNumber to convert
Returns
Stringized conversion of the number

Definition at line 18 of file itos.h.