473,666 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.co m
Nov 14 '05 #1
10 3304
In article <41******@news. uni-ulm.de>,
Christian Staudenmayer <cs****@gmail.c om> 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.c om> 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 misunderstandin g 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.co m
Nov 14 '05 #3
dj******@csclub .uwaterloo.ca (Dave Vandervies) writes:
In article <41******@news. uni-ulm.de>,
Christian Staudenmayer <cs****@gmail.c om> 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.c om> 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 misunderstandin g 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**********@i nvalid.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**********@i nvalid.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********@yah oo.com) (cb********@wor ldnet.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********@wor ldnet.att.net> wrote:
Chris Croughton wrote:
<Mi**********@i nvalid.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********@wor ldnet.att.net> wrote:
Chris Croughton wrote:
<Mi********* *@invalid.inval id> 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

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

Similar topics

14
2772
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 am I missing? If that's all, then why did Bjarne even bother adding it to the language? If that's not all, what else can I do with "inline"?
9
2056
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;} A::~A(){cout <<"destr A"<<endl;} inline void A::showA() {cout << "show A: i =" << i <<endl;}; //////////////////////// classes_1.h
14
2103
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 into a program: /* source1.cpp */ inline int Func(double arg) {
2
8681
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 with two divs to get them to render side by side: <div style="width:12em;border: 2px solid #EFCE8C; padding: 0.5em;display:inline;">abc</div> <div style="width:12em;border: 2px solid #EFCE8C; padding:
12
11535
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 an associated application, there are the Content-Disposition type options of "inline" or "extension-token". Specifically as regards Internet Explorer, I've tried both inline and the specific filename extension (xls,csv,pdf,doc,...) and the...
3
3142
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 across all browsers, but there seem to be a few very similar solutions, so that is probably not a major hurdle. However, just to complicate things, I want to have it "inline" (http:// www.tizag.com/cssT/inline.php)
17
8369
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 the function if possible" (because if the compiler has the function definition available at an instantiation point, it will estimate whether to inline it or not, and do so if it estimates it would be beneficial, completely regardless of whether...
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7378
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.