Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define a macro off of the content of a macro

Tags:

c

macros

Is it possible to define a macro off of the content of a macro?

For example:

#define SET(key,value) #define key value

SET(myKey,"value")

int main(){
   char str[] = myKey;
   printf("%s",str);
}

would result in

int main(){
   char str[] = "value";
   printf("%s",str);
}

after being preprocessed.

Why would I do this? Because I'm curious ;)

like image 452
Linsey Avatar asked Sep 24 '11 18:09

Linsey


1 Answers

No, its not possible to define a macro within another macro.

like image 85
K-ballo Avatar answered Sep 20 '22 17:09

K-ballo