D
dspfun
I was asked whether it is possible to prepend a name (using macro
substitution) to all function names in a file/program.
For example, the functions f1(), f2(), f3() should get aa_ prepended
to their names?
I.e., f1(), f2(), f3() should be changed to aa_f1(), aa_f2(), aa_f3()
using some macro substitution.
I came up with the following:
****************************************************
#include <stdio.h>
#define PREPEND aa_
#define MAKE_FUNC_NAME(prepend, func_name) prepend ## func_name
void MAKE_FUNC_NAME(PREPEND, f1)(void)
{
printf("here..\n");
}
****************************************************
However, this does not define the function aa_f1, instead the function
PREPENDf1 is defined. Why? Is there some way to get around this to
achieve what is set out to be done?
substitution) to all function names in a file/program.
For example, the functions f1(), f2(), f3() should get aa_ prepended
to their names?
I.e., f1(), f2(), f3() should be changed to aa_f1(), aa_f2(), aa_f3()
using some macro substitution.
I came up with the following:
****************************************************
#include <stdio.h>
#define PREPEND aa_
#define MAKE_FUNC_NAME(prepend, func_name) prepend ## func_name
void MAKE_FUNC_NAME(PREPEND, f1)(void)
{
printf("here..\n");
}
****************************************************
However, this does not define the function aa_f1, instead the function
PREPENDf1 is defined. Why? Is there some way to get around this to
achieve what is set out to be done?