Is "inline" valid C?

Discussion in 'C Programming' started by Christian Staudenmayer, Dec 6, 2004.

  1. Hi,

    is there any revision of the C standard that allows the "inline" keyword
    (or a similar feature)? I know it is possible in gcc, but then it might
    be a gcc feature only.

    Greetings, Chris

    --
    Christian Staudenmayer
    University of Ulm, Germany
    Christian Staudenmayer, Dec 6, 2004
    #1
    1. Advertising

  2. In article <-ulm.de>,
    Christian Staudenmayer <> wrote:
    >
    >Hi,
    >
    >is there any revision of the C standard that allows the "inline" keyword
    >(or a similar feature)? I know it is possible in gcc, but then it might
    >be a gcc feature only.


    It's in C99, and also widely implemented as an extension.

    If you don't use "inline" as an identifier, you can make its use in a
    declaration valid-and-ignored on implementations that don't have it by
    simply #defining it to nothing:

    #ifndef HAS_INLINE
    #define inline /*Nothing to see here, move along*/
    #endif


    dave

    --
    Dave Vandervies
    If you make an error while making a valid point, you can expect us to
    point out the error. If you later claim not to have committed the
    error, you can expect to be flamed. --Keith Thompson in comp.lang.c
    Dave Vandervies, Dec 6, 2004
    #2
    1. Advertising

  3. Christian Staudenmayer

    Ben Pfaff Guest

    (Dave Vandervies) writes:

    > In article <-ulm.de>,
    > Christian Staudenmayer <> wrote:
    >>is there any revision of the C standard that allows the "inline" keyword
    >>(or a similar feature)? I know it is possible in gcc, but then it might
    >>be a gcc feature only.

    >
    > It's in C99, and also widely implemented as an extension.


    However, the semantics implemented by GCC, and presumably by
    some other compilers, differ from those specified by C99.
    --
    Ben Pfaff
    email:
    web: http://benpfaff.org
    Ben Pfaff, Dec 6, 2004
    #3
  4. Dave Vandervies wrote:
    > In article <-ulm.de>,
    > Christian Staudenmayer <> wrote:
    >
    >>Hi,
    >>
    >>is there any revision of the C standard that allows the "inline" keyword
    >>(or a similar feature)? I know it is possible in gcc, but then it might
    >>be a gcc feature only.

    >
    >
    > It's in C99, and also widely implemented as an extension.
    >
    > If you don't use "inline" as an identifier, you can make its use in a
    > declaration valid-and-ignored on implementations that don't have it by
    > simply #defining it to nothing:
    >
    > #ifndef HAS_INLINE
    > #define inline /*Nothing to see here, move along*/
    > #endif
    >
    >
    > dave
    >


    I think I have a misunderstanding of gcc's command line options, because
    -ansi yielded an error regarding "inline". But apparently -ansi means
    the same as -std=c89 (i.e. C90).

    So, if I use -std=c99 I can use "inline" and still be sure that the
    compiler will warn me of any violations of the standard?

    Greetings, Chris.

    --
    Christian Staudenmayer
    University of Ulm, Germany
    Christian Staudenmayer, Dec 6, 2004
    #4
  5. Christian Staudenmayer

    Michael Mair Guest

    Christian Staudenmayer wrote:

    > Dave Vandervies wrote:
    >
    >> In article <-ulm.de>,
    >> Christian Staudenmayer <> wrote:
    >>
    >>> Hi,
    >>>
    >>> is there any revision of the C standard that allows the "inline"
    >>> keyword (or a similar feature)? I know it is possible in gcc, but
    >>> then it might be a gcc feature only.

    >>
    >>
    >>
    >> It's in C99, and also widely implemented as an extension.
    >>
    >> If you don't use "inline" as an identifier, you can make its use in a
    >> declaration valid-and-ignored on implementations that don't have it by
    >> simply #defining it to nothing:
    >>
    >> #ifndef HAS_INLINE
    >> #define inline /*Nothing to see here, move along*/
    >> #endif
    >>
    >>
    >> dave
    >>

    >
    > I think I have a misunderstanding of gcc's command line options, because
    > -ansi yielded an error regarding "inline". But apparently -ansi means
    > the same as -std=c89 (i.e. C90).
    >
    > So, if I use -std=c99 I can use "inline" and still be sure that the
    > compiler will warn me of any violations of the standard?


    If you use -std=c99 -pedantic, it should do so.
    However, the C99 status page (gcc.gnu.org/c99status.html) admits that
    this is still not guaranteed. OTOH, even -ansi -pedantic does not grant
    that gcc will do the right thing for standard conforming C89 programs.


    Cheers
    Michael
    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.
    Michael Mair, Dec 6, 2004
    #5
  6. On Mon, 06 Dec 2004 20:19:57 +0100, Michael Mair
    <> wrote:

    > If you use -std=c99 -pedantic, it should do so.
    > However, the C99 status page (gcc.gnu.org/c99status.html) admits that
    > this is still not guaranteed. OTOH, even -ansi -pedantic does not grant
    > that gcc will do the right thing for standard conforming C89 programs.


    Does any compiler "do the right thing" with either of the standards? If
    so, which (preferably a free one which runs on any platform)? All the
    compilers I've ever used either don't reach the standard or they have
    nonstandard extensions (in particular, I've never seen a library which
    supports all of the C99 functions correctly).

    Chris C
    Chris Croughton, Dec 6, 2004
    #6
  7. Christian Staudenmayer

    CBFalconer Guest

    Chris Croughton wrote:
    > <> wrote:
    >
    >> If you use -std=c99 -pedantic, it should do so. However, the C99
    >> status page (gcc.gnu.org/c99status.html) admits that this is still
    >> not guaranteed. OTOH, even -ansi -pedantic does not grant that gcc
    >> will do the right thing for standard conforming C89 programs.

    >
    > Does any compiler "do the right thing" with either of the standards?
    > If so, which (preferably a free one which runs on any platform)?
    > All the compilers I've ever used either don't reach the standard or
    > they have nonstandard extensions (in particular, I've never seen a
    > library which supports all of the C99 functions correctly).


    While I am sure that faults can be found with "gcc -ansi -pedantic"
    operation, I have yet to run into them. AFAICT it suppresses all
    the gnu extensions. Libraries are a separate matter, and you
    should probably report any library failings. The only C99 library
    known to me is from Gimpel.

    --
    Chuck F () ()
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net> USE worldnet address!
    CBFalconer, Dec 6, 2004
    #7
  8. In article <>,
    CBFalconer <> wrote:
    >Chris Croughton wrote:
    >> <> wrote:
    >>
    >>> If you use -std=c99 -pedantic, it should do so. However, the C99
    >>> status page (gcc.gnu.org/c99status.html) admits that this is still
    >>> not guaranteed. OTOH, even -ansi -pedantic does not grant that gcc
    >>> will do the right thing for standard conforming C89 programs.

    >>
    >> Does any compiler "do the right thing" with either of the standards?
    >> If so, which (preferably a free one which runs on any platform)?
    >> All the compilers I've ever used either don't reach the standard or
    >> they have nonstandard extensions (in particular, I've never seen a
    >> library which supports all of the C99 functions correctly).

    >
    >While I am sure that faults can be found with "gcc -ansi -pedantic"
    >operation, I have yet to run into them. AFAICT it suppresses all
    >the gnu extensions. Libraries are a separate matter, and you
    >should probably report any library failings. The only C99 library
    >known to me is from Gimpel.


    Dinkumware also has one, don't they?

    Most compilers will do C90, modulo bugs, if you can figure out how to
    ask them to. A lot are making serious efforts at C99, but I don't have
    up-to-date knowledge on which ones are how close. Comeau was, I believe,
    the first to advertise complete compliance (on the language side only,
    but it plays nicely with the Dinkumware library to get a complete
    implementation); I'm not sure if it's been joined by others yet.


    dave

    --
    Dave Vandervies

    The pedants here will shout "int main(void)" but I'll just whisper it.
    --Bob Wightman in comp.lang.c
    Dave Vandervies, Dec 6, 2004
    #8
  9. Dave Vandervies wrote:

    > Comeau was, I believe, the first to advertise complete compliance
    > (on the language side only, but it plays nicely with the Dinkumware library
    > to get a complete implementation);


    Comeau

    http://www.comeaucomputing.com/

    doesn't actually claim full compliance with ANSI/ISO standards.

    "This combination of Comeau and Dinkumware
    is as close as you can get to full compliance
    with Standard C++ from 2003 or 1998,
    Standard C from 1999 (aka C99) and
    Standard C from 1990 (aka C90)."
    E. Robert Tisdale, Dec 6, 2004
    #9
  10. Christian Staudenmayer

    Michael Mair Guest

    Dave Vandervies wrote:

    > In article <>,
    > CBFalconer <> wrote:
    >
    >>Chris Croughton wrote:
    >>
    >>><> wrote:
    >>>
    >>>>If you use -std=c99 -pedantic, it should do so. However, the C99
    >>>>status page (gcc.gnu.org/c99status.html) admits that this is still
    >>>>not guaranteed. OTOH, even -ansi -pedantic does not grant that gcc
    >>>>will do the right thing for standard conforming C89 programs.
    >>>
    >>>Does any compiler "do the right thing" with either of the standards?


    I do not know that.

    >>>If so, which (preferably a free one which runs on any platform)?
    >>>All the compilers I've ever used either don't reach the standard or
    >>>they have nonstandard extensions (in particular, I've never seen a
    >>>library which supports all of the C99 functions correctly).


    If I knew one, I would gladly advertise it :)
    The Dinkumware library claims C99 compliance.


    >>While I am sure that faults can be found with "gcc -ansi -pedantic"
    >>operation, I have yet to run into them. AFAICT it suppresses all
    >>the gnu extensions. Libraries are a separate matter, and you
    >>should probably report any library failings. The only C99 library
    >>known to me is from Gimpel.


    Well, the things I ran into are mainly related to the problem that
    typecasting to a certain floating point type does not work on x86
    architectures because the gcc people rather accept excess precision
    plus fast execution than the right precision plus slow execution...
    There are some algorithms which do not work as expected when
    you have excess precision for some expressions but not for others.
    The thing I am unhappy about is that they do not document this
    where everyone finds it. A mention along with the -std=... option
    would suffice.


    > Dinkumware also has one, don't they?


    Yep.

    > Most compilers will do C90, modulo bugs, if you can figure out how to
    > ask them to. A lot are making serious efforts at C99, but I don't have
    > up-to-date knowledge on which ones are how close. Comeau was, I believe,
    > the first to advertise complete compliance (on the language side only,
    > but it plays nicely with the Dinkumware library to get a complete
    > implementation); I'm not sure if it's been joined by others yet.


    AFAIK, Comeau plus Dinkumware libraries is still the only compliant
    combination.

    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.
    Michael Mair, Dec 7, 2004
    #10
  11. In article <>, Michael Mair <> writes:
    > Dave Vandervies wrote:
    >
    > > A lot are making serious efforts at C99, but I don't have
    > > up-to-date knowledge on which ones are how close.

    >
    > AFAIK, Comeau plus Dinkumware libraries is still the only compliant
    > combination.


    I recently discovered that HP appears to claim its current Compaq C
    implementation for OpenVMS for Alpha (only) is C99-compliant.[1]

    I'm sure that's a great comfort to the hordes of Alpha OpenVMS users
    out there, as HP gradually starves all of the former-Digital, former-
    Compaq platforms to death.

    Why HP can't provide a C99-compliant implementation for, say, HP-UX
    is a mystery. The version we're using right now doesn't even have a
    conforming snprintf. (Ditto the one for Tru64, another orphan HP has
    kicked out into the cold.)

    And to drag another recent thread back in: we were recently discussing
    pre-ISO code that was still in use. Much of our C source has nasty
    conditional-compilation sections that substitute K&R function
    definitions for ISO ones. I was looking to get rid of those and
    discovered that we're still contractually obligated to support a few
    pre-standard implementations - 14 years after the first ISO standard.
    (Apparently whatever implementation we're using for SINIX is one; for
    all I know Fujitsu-Siemens now has a conforming implementation avail-
    able for it, but switching implementations on a maintenance-only
    platform is probably not a good idea.)


    1. <http://h71000.www7.hp.com/commercial/c/docs/5492p001.html>; look
    for "Strict C99".

    --
    Michael Wojcik

    Pocket #9: A complete "artificial glen" with rocks, and artificial moon,
    and forester's station. Excellent for achieving the effect of the
    sublime without going out-of-doors. -- Joe Green
    Michael Wojcik, Dec 9, 2004
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abhi
    Replies:
    2
    Views:
    736
    E. Robert Tisdale
    Jul 3, 2003
  2. Alvin
    Replies:
    7
    Views:
    474
    E. Robert Tisdale
    May 6, 2005
  3. Replies:
    3
    Views:
    457
  4. Daniel Vallstrom
    Replies:
    2
    Views:
    1,879
    Kevin Bracey
    Nov 21, 2003
  5. Nish
    Replies:
    4
    Views:
    490
    Thomas Stegen
    Oct 8, 2004
Loading...

Share This Page