0

Possible Duplicate:
C Preprocessor, Stringify the result of a macro

Shortly:

#include <iostream>

float pi(){ return 3.14; }

#define PRINT(x) std::cout << #x << std::endl;

#define PI pi()

int main(int argc, char *argv[])
{
    PRINT(PI)
    PRINT(pi())
    return 0;
}

Result:

PI
pi()

Is there any way to get only preprocessed data in macro argument? To get as a result

pi()
pi()

?

EDIT:

I haven't noticed this question: C Preprocessor, Stringify the result of a macro Duplicate...

Community
  • 1
  • 1
j_kubik
  • 6,062
  • 1
  • 23
  • 42

1 Answers1

0

Add another helper macro:

#define QU(x) #x
#define PRINT(x) std::cout << QU(x) << std::endl;
#define PI pi()
Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084