Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Kaz Kylheku <kaz@kylheku.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: inline |
| Date | 2011-11-03 20:10 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <20111103155816.965@kylheku.com> (permalink) |
| References | <j8ubn1$6vb$1@speranza.aioe.org> <87mxcdfair.fsf@blp.benpfaff.org> <j8upic$fu8$1@speranza.aioe.org> |
On 2011-11-03, Mark <mark_cruzNOTFORSPAM@hotmail.com> wrote:
>
> "Ben Pfaff" <blp@cs.stanford.edu> wrote in message
> news:87mxcdfair.fsf@blp.benpfaff.org...
>>> is it required to have 'inline' keywoard before type in a function
>>> definition/declaration? For example, what is correct:
>>>
>>> inline int small_func(void)
>>> {
>>> /* do something */
>>> }
>>>
>>> or
>>>
>>> int inline small_func(void)
>>> {
>>> /* do something */
>>> }
>>
>> Both are correct but the former is customary.
>>
>>> Also - is the same true for functions having static definition?
>
> For the second case "gcc -std=c99 -pedantic -W -Wall" gives warning: 'inline'
> is not at beginning of declaration. Why does gcc care about the sequence if
> both representations are correct ?
gcc doesn't provide warnings about only what is incorrect, but also
stylistic warnings. This is also correct:
(a && b || c)
So is this
while (x = 0) { ... }
The above could be potential bugs, though.
Furthermore, some of GCC's warnings also helps with portability issues. Inline
functions were an extension in many C compilers for a long time. Maybe not all
C compilers with an inline extension allowed the keyword to be in any position
among the specifiers.
This might be something that has been in GCC for some time. It's also issued
for the GNU C dialect (that you get if you don't use -ansi or -std=c99).
The minimal set of options that obtain this warning are:
gcc -W foo.c
By the way, I also tried the C++ front end (gcc 4.4.1) and see that it does
not have such a warning. It's implemented in the C front end only.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
inline "Mark" <mark_cruzNOTFORSPAM@hotmail.com> - 2011-11-03 11:13 -0400
Re: inline blp@cs.stanford.edu (Ben Pfaff) - 2011-11-03 09:14 -0700
Re: inline "Mark" <mark_cruzNOTFORSPAM@hotmail.com> - 2011-11-03 15:20 -0400
Re: inline blp@cs.stanford.edu (Ben Pfaff) - 2011-11-03 12:50 -0700
Re: inline Kaz Kylheku <kaz@kylheku.com> - 2011-11-03 20:10 +0000
Re: inline Keith Thompson <kst-u@mib.org> - 2011-11-03 13:51 -0700
csiph-web