2

I wonder that is it possible to define "define" as a macro? Like that

#define A #define
A MAX_SIZE 100
A MIN_SIZE 0

Can I define it? (in c++)

Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
Marc Blume
  • 79
  • 1
  • 2
  • 8
  • 6
    What on Earth are you trying to do? – Ed Heal Jan 08 '16 at 22:29
  • 1
    You should not obfuscate your code. If you are too lazy to type, use an editor with text-completion. – too honest for this site Jan 08 '16 at 22:30
  • 4
    You can do it but the pre-processor won't interpret it as a directive, you you'd end up with a literal `#define MAX_SIZE 100` in your code that will lead to a syntax error during the compilation phase. – 5gon12eder Jan 08 '16 at 22:30
  • I heard you like defines - so I put some defines in your defines so you can define while you define... Seriously, even if that worked, that would be a bad idea. Constants are a better way of doing this in C++. – void_ptr Jan 08 '16 at 23:16
  • 1
    Guys, I know how to use #define and why it uses. But, i have limit of character. So I have to complete my code as short as possible. – Marc Blume Jan 08 '16 at 23:40
  • If you want short code (golfing?) then write 0 as 0. You're not going to get shorter than that. And `int x=100,u=50;` is also shorter than macro definitions. Iow, macros suck even in golf. (You can shorten typenames with `typedef` but it's rarele useful.) – rici Jan 09 '16 at 03:11

3 Answers3

5

No. The result of macro expansions will not be treated as new macro directives.

Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
2

You cannot do this, because the second #define won't be parsed as another preprocessor directive.

lost_in_the_source
  • 10,998
  • 9
  • 46
  • 75
0

You would have to write your own custom preprocessor to do this, like in this post:

Custom gcc preprocessor

Community
  • 1
  • 1
bruceg
  • 2,433
  • 1
  • 22
  • 29