Ways to define C constants

Discussion in 'C Programming' started by James Harris, Jun 2, 2014.

  1. 0x74.

    But that's set at one point in the program, in main. Then it is passed down. So at all places,
    the address of port a is held in a variable, except the one place where it is set.
    Malcolm McLean, Jun 3, 2014
    1. Advertisements

  2. James Harris

    James Harris Guest

    I suppose I am at fault for trying to summarise.... I should have known
    better. Anyway, I was *not* referring to differences from the standards. We
    discussed this topic about a year ago and I have some useful code as a
    result. This is not the time to rehash that thread.

    James Harris, Jun 3, 2014
    1. Advertisements

  3. James Harris

    Kleuske Guest

    I stand corrected. Sloppy use of terminology on my side.
    Kleuske, Jun 3, 2014
  4. James Harris

    Richard Bos Guest

    Thank you.

    Is there any place which accurately documents the differences between
    this and the official standard? And those between C11 and C99?
    I could do a websearch, but if there's somewhere official I'd rather
    rely on that.

    Richard Bos, Jun 4, 2014
  5. The foreword of N1570 and C11 includes a summary of the major changes
    between C99 and C11.

    I don't know of an *official* summary of differences between N1570 and
    C11, but I asked Larry Jones (a committee member) about it in comp.std.c
    last year:

    Newsgroups: comp.std.c
    Subject: Re: Array operand of _Alignof
    Date: Fri, 5 Apr 2013 14:07:23 -0400
    Message-ID: <>

    There are a number of them, but most are just minor editorial tweaks,
    changes to boilerplate text, and shuffling things around to keep the
    powers that be happy. The biggest change was removing _Alignof from a
    bunch of places it shouldn't have been added (based on the erroneous
    notion that it takes either a type or an expression like sizeof does
    when it really only takes a type):, p3, p4, fn. 65; and 6.7.1
    fn. 121.
    Larry Jones

    There has also been one Technical Corrigendum. Both N1570
    and C11 failed to define proper values for __STDC_VERSION__ and
    __STDC_LIB_EXT1__; the TC specifies both as 201112L. (The latter is
    defined only by implementations that support Annex K (Bounds-checking
    Keith Thompson, Jun 4, 2014
  6. James Harris

    Richard Bos Guest

    Hm? Oh, it doesn't open at the first page!

    I see they've finally removed gets(). That's one good change to begin

    Thanks again.

    Richard Bos, Jun 5, 2014
  7. James Harris

    Jorgen Grahn Guest

    That doesn't tell me anything, I'm afraid. In my world a "port" is an
    UDP, TCP or SCTP port, and that's clearly not what you have in mind.
    Fourth option: isolate its use to one function and use the literal
    there. Assuming it's a BSD socket port:

    int my_specific_listening_socket(const char* host)
    // ...
    getaddrinfo(host, "112", ...);
    // ...
    return fd;

    IME, a surprising number of these constants can be wrapped into
    code: the constant itself isn't important but what it's used for.

    It's easier to document and understand a function, than a constant.

    Jorgen Grahn, Jun 6, 2014
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.