Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

138
Vistas
Use name of #define parameter without stringification

Is there a way to get the exact words passed into the #define without stringifying? Example use case:

#define NUM 1

#define CREATE_FUN(X) \
void prefix_X() { \ // used exact words passed in
    int x = X; \ // use value later on
}

CREATE_FUN(NUM)

And output would look like:

void prefix_NUM() {
    int x = 1;
}
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Use the token concatenation (##):

#define NUM 1

#define CREATE_FUN(X) \
void prefix_##X() { \
    int x = X; \
}

CREATE_FUN(NUM)
over 4 years ago · Santiago Trujillo Denunciar

0

#define CREATE_FUN(X) \
int prefix_##X() { \
    int x = X; \
    return x; \
}

CREATE_FUN(NUM)
over 4 years ago · Santiago Trujillo Denunciar

0

You can use Token Pasting(##) operator:

#define CREATE_FUN(X) int prefix_##X() { int x=X; return x;}

Sample use case:

Some compilers provide an extension that allows ## to appear after a comma and before __VA_ARGS__, in which case

  1. the ## does nothing when VA_ARGS is non-empty

  2. removes the comma when VA_ARGS is empty.

This makes it possible to define macros with variable number of arguments such as fprintf (stderr, format, ##__VA_ARGS__)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda