Multi-word #define

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Army1987

    Multi-word #define

    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;
    }


  • Eric Sosman

    #2
    Re: Multi-word #define

    Army1987 wrote:
    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.

    --
    Eric Sosman
    esosman@acm-dot-org.invalid

    Comment

    • Ben Pfaff

      #3
      Re: Multi-word #define

      "Army1987" <please.ask@for .itwrites:
      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.
      --
      Comp-sci PhD expected before end of 2007
      Seeking industrial or academic position *outside California* in 2008

      Comment

      Working...