Here is a solution I came up with after reading a bit online.
Basically, in order to get the number to show up in the signature you need to stringify the argument. If you stringify an argument, the prescan does not complete which results in your fooBAZ function definition (it did not fully expand)
If you use another macro intermediary it will complete the expansion.
Here is a link that explains further about prescan and the times it is not completed.
// Testing.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#define BAZ 0
#define QUXdef(x) QUX(x)
#define QUX(x) foo##x()
#define QUXimp(x) DEF(x)
#define DEF(x) foo##x()
//Function Def
void QUXdef(BAZ);
int main(int argc, char* argv[])
{
foo0();
}
void QUXimp(BAZ)
{
printf("Hello world\n");
}
NOTE: I included another set of macros for implementing the function. You did not ask for this, but I figured it would be more "complete" if defining and implementing functions was your goal. QUXdef and QUX fulfill your specific needs.
Edit 1:
- I removed C++-style code from the solution. It was brought to my attention by Jens Gustedt and is a valid critique considering this was tagged as C(My fault for not reading fully).
- I also removed the ; form the macro itself. It is now supplied by the user instead which is much more readable. This was also a valid critique from Jens Gustedt
- I took void out of the macro expansion. Instead I let the user define the return type. To me this seems to also allow for more readability.
- I removed the stdafx statement considering this is for C code and visual studio is less likely to be used by pure C programmers. As it sits, this should be able to be copied and pasted into a file and then compiled by GCC or some other more popular C compiler.
Otherwise, this answer is solid and if you look at the link I provided it explains the need for an intermediary macro to get the proper expansion the Asker is looking for.