473,382 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Is "inline" valid C?


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
cs****@gmail.com
Nov 14 '05 #1
10 3282
In article <41******@news.uni-ulm.de>,
Christian Staudenmayer <cs****@gmail.com> 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 dj******@csclub.uwaterloo.ca
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
Nov 14 '05 #2
Dave Vandervies wrote:
In article <41******@news.uni-ulm.de>,
Christian Staudenmayer <cs****@gmail.com> 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
cs****@gmail.com
Nov 14 '05 #3
dj******@csclub.uwaterloo.ca (Dave Vandervies) writes:
In article <41******@news.uni-ulm.de>,
Christian Staudenmayer <cs****@gmail.com> 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: bl*@cs.stanford.edu
web: http://benpfaff.org
Nov 14 '05 #4
Christian Staudenmayer wrote:
Dave Vandervies wrote:
In article <41******@news.uni-ulm.de>,
Christian Staudenmayer <cs****@gmail.com> 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.
Nov 14 '05 #5
On Mon, 06 Dec 2004 20:19:57 +0100, Michael Mair
<Mi**********@invalid.invalid> 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
Nov 14 '05 #6
Chris Croughton wrote:
<Mi**********@invalid.invalid> 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 (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #7
In article <41**************@yahoo.com>,
CBFalconer <cb********@worldnet.att.net> wrote:
Chris Croughton wrote:
<Mi**********@invalid.invalid> 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 dj******@csclub.uwaterloo.ca

The pedants here will shout "int main(void)" but I'll just whisper it.
--Bob Wightman in comp.lang.c
Nov 14 '05 #8
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)."
Nov 14 '05 #9
Dave Vandervies wrote:
In article <41**************@yahoo.com>,
CBFalconer <cb********@worldnet.att.net> wrote:
Chris Croughton wrote:
<Mi**********@invalid.invalid> 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.
Nov 14 '05 #10

In article <31*************@individual.net>, Michael Mair <Mi**********@invalid.invalid> 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 mi************@microfocus.com

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
Nov 14 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Chris Mantoulidis | last post by:
I am not clear with the use of the keyword inline... I believe you add it do a function when you implement the function inside the header file where the class is stored... But is that all? What...
9
by: John Rambo | last post by:
Hi, I made the following test program: //////////////////////// classes_1.cpp #include <iostream> #include "classes_1.h" using namespace std; A::A():i(0){cout <<"const A: i =" << i <<endl;}...
14
by: Frederick Gotham | last post by:
The original purpose of "inline" was that code could be "expanded in place". Of course, it has other uses... For one thing, the following two translation units will compile together succesfully...
2
by: Steve Richter | last post by:
I would like to use display:inline and other CSS attributes to build an entry form. Where the heading to the left of the text box is always a set width. It is not working so I am experimenting...
12
by: Dave H. | last post by:
Please redirect me if this message is posted to the wrong group. Given the intention of delivering content to an HTTP user agent (such as Internet Explorer) which is to be immediately opened by...
3
by: Baron Samedi | last post by:
I am looking for a reliable cross-browser pull-quote solution in CSS. See for instance, http://www.sitepoint.com/examples/pullquotes/ The problem seems at first to be sure that it functions...
17
by: Juha Nieminen | last post by:
As we know, the keyword "inline" is a bit misleading because its meaning has changed in practice. In most modern compilers it has completely lost its meaning of "a hint for the compiler to inline...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.