-1

I used a library to work with ST microcontroller. But I have not understood this define. Does anyone know anything about it.

#define CONCAT(x, y)            x ## y
Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
sn01
  • 36
  • 6

2 Answers2

0

As the name of the macro sounds it concatenates its arguments.

Here is a demonstration program.

#include <stdio.h>

#define CONCAT(x, y)            x ## y

int main( void ) 
{
    int CONCAT( my, Variable ) = 10;
    printf( "%d\n", myVariable );
}

In the program there is declared a variable with the name myVariable.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
0

As the macro name suggests, the preprocessor operator ## concatenates two tokens together.

#include <stdio.h> 

#define CONCAT(x, y)            x ## y

int main()
{
    int ab = 4;
    printf("%d\n", CONCAT(a,b));
    return 0;
}
dbush
  • 205,898
  • 23
  • 218
  • 273