Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Is "inline" valid C?

Reply
Thread Tools

Is "inline" valid C?

 
 
Christian Staudenmayer
Guest
Posts: n/a
 
      12-06-2004

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
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Dave Vandervies
Guest
Posts: n/a
 
      12-06-2004
In article <(E-Mail Removed)-ulm.de>,
Christian Staudenmayer <(E-Mail Removed)> 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 (E-Mail Removed)
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
 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      12-06-2004
(E-Mail Removed) (Dave Vandervies) writes:

> In article <(E-Mail Removed)-ulm.de>,
> Christian Staudenmayer <(E-Mail Removed)> 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: (E-Mail Removed)
web: http://benpfaff.org
 
Reply With Quote
 
Christian Staudenmayer
Guest
Posts: n/a
 
      12-06-2004
Dave Vandervies wrote:
> In article <(E-Mail Removed)-ulm.de>,
> Christian Staudenmayer <(E-Mail Removed)> 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
(E-Mail Removed)
 
Reply With Quote
 
Michael Mair
Guest
Posts: n/a
 
      12-06-2004
Christian Staudenmayer wrote:

> Dave Vandervies wrote:
>
>> In article <(E-Mail Removed)-ulm.de>,
>> Christian Staudenmayer <(E-Mail Removed)> 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.
 
Reply With Quote
 
Chris Croughton
Guest
Posts: n/a
 
      12-06-2004
On Mon, 06 Dec 2004 20:19:57 +0100, Michael Mair
<(E-Mail Removed)> 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
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      12-06-2004
Chris Croughton wrote:
> <(E-Mail Removed)> 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 ((E-Mail Removed)) ((E-Mail Removed))
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

 
Reply With Quote
 
Dave Vandervies
Guest
Posts: n/a
 
      12-06-2004
In article <(E-Mail Removed)>,
CBFalconer <(E-Mail Removed)> wrote:
>Chris Croughton wrote:
>> <(E-Mail Removed)> 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 (E-Mail Removed)

The pedants here will shout "int main(void)" but I'll just whisper it.
--Bob Wightman in comp.lang.c
 
Reply With Quote
 
E. Robert Tisdale
Guest
Posts: n/a
 
      12-06-2004
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)."
 
Reply With Quote
 
Michael Mair
Guest
Posts: n/a
 
      12-07-2004
Dave Vandervies wrote:

> In article <(E-Mail Removed)>,
> CBFalconer <(E-Mail Removed)> wrote:
>
>>Chris Croughton wrote:
>>
>>><(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not valid SSID name during setup using the wizard =?Utf-8?B?SE1WYWNhbmE=?= Wireless Networking 4 08-23-2005 05:38 PM
Enigmail - no valid OpenPGP data found Chuck Firefox 3 04-27-2005 09:20 PM
Enigmail - no valid OpenPGP data found Chuck Firefox 0 04-26-2005 06:41 PM
User Control - InvalidCastException: Specified cast is not valid Ajit ASP .Net 1 04-24-2004 09:28 PM
Valid file types Aschel Kritsos ASP .Net 1 11-14-2003 05:13 PM



Advertisments