Multi-word #define

A

Army1987

Is there a way to #define a sequence of several identifiers into something
else?
For example, suppose I write:

#include <limits.h>
#ifndef LLONG_MAX /* C89 */
#define LLONG_MAX LONG_MAX
#define LLONG_MIN LONG_MIN
#define ULLONG_MAX ULONG_MAX
#define long_long long
#else /* C99 */
#define long_long long long
#endif

Can I simply write something such as #define (long long) long, so that I
don't need the else branch above, and I don't have to use non-standard
identifiers such as long_long?

--
#include <stdio.h>
#include <stdlib.h>
int main(void) /* Don't try this at home */ {
const size_t dim = 256; int i;
for (i=0; malloc(dim); i++) /*nothing*/ ;
printf("You're done! %zu\n", i*dim);
puts("\n\n--Army1987"); return 0;
}
 
B

Ben Pfaff

Army1987 said:
Can I simply write something such as #define (long long) long, so that I
don't need the else branch above, and I don't have to use non-standard
identifiers such as long_long?

No, there's no way to do that.
 
E

Eric Sosman

Army1987 said:
Is there a way to #define a sequence of several identifiers into something
else?
For example, suppose I write:

#include <limits.h>
#ifndef LLONG_MAX /* C89 */
#define LLONG_MAX LONG_MAX
#define LLONG_MIN LONG_MIN
#define ULLONG_MAX ULONG_MAX
#define long_long long
#else /* C99 */
#define long_long long long
#endif

Can I simply write something such as #define (long long) long, so that I
don't need the else branch above, and I don't have to use non-standard
identifiers such as long_long?

No. One identifier <-> one macro.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top