Original Post
🔒 Locked
Even more #define macros
Advertisement
Nope, you can't do that. However, you can pass Hello to the function, and use #x if you need to convert to a const char*
EDIT: Some code:
Ok, that's a really bad example :P
EDIT: Some code:
#define Func(x) printf("%s",#x);Func(Hello)Ok, that's a really bad example :P
[lol] Rob, here's a start for you:
You were close to being with, but see what I did to get around the error you had, with the "_" and space?[wink]. I think I know what you are trying to do, and I think I had tried it before and could not get it to work, but then again, I could not of had made this code work either. Something to play with. I will work with this though, I think you may be able to do some intresting stuff with this.
- Drew
#include <stdio.h>#include <stdlib.h>#define CF1(x) void _ ## x ## (int b)#define CF2(x,y) CF1(x) { printf("%i",y); abort(); }CF2(HI,2)int main( int argc, char** argv ){ _HI(0); // 0 does not work b/c of the 2 above return 0;}You were close to being with, but see what I did to get around the error you had, with the "_" and space?[wink]. I think I know what you are trying to do, and I think I had tried it before and could not get it to work, but then again, I could not of had made this code work either. Something to play with. I will work with this though, I think you may be able to do some intresting stuff with this.
- Drew
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement