Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #12591 > unrolled thread
| Started by | "Mark" <mark_cruzNOTFORSPAM@hotmail.com> |
|---|---|
| First post | 2011-11-03 11:13 -0400 |
| Last post | 2011-11-03 13:51 -0700 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.c
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
| From | "Mark" <mark_cruzNOTFORSPAM@hotmail.com> |
|---|---|
| Date | 2011-11-03 11:13 -0400 |
| Subject | inline |
| Message-ID | <j8ubn1$6vb$1@speranza.aioe.org> |
Hello
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 */
}
Also - is the same true for functions having static definition?
Thanks.
Mark
[toc] | [next] | [standalone]
| From | blp@cs.stanford.edu (Ben Pfaff) |
|---|---|
| Date | 2011-11-03 09:14 -0700 |
| Message-ID | <87mxcdfair.fsf@blp.benpfaff.org> |
| In reply to | #12591 |
"Mark" <mark_cruzNOTFORSPAM@hotmail.com> writes:
> 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?
Same answer.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
[toc] | [prev] | [next] | [standalone]
| From | "Mark" <mark_cruzNOTFORSPAM@hotmail.com> |
|---|---|
| Date | 2011-11-03 15:20 -0400 |
| Message-ID | <j8upic$fu8$1@speranza.aioe.org> |
| In reply to | #12596 |
"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 ?
Thanks.
Mark
[toc] | [prev] | [next] | [standalone]
| From | blp@cs.stanford.edu (Ben Pfaff) |
|---|---|
| Date | 2011-11-03 12:50 -0700 |
| Message-ID | <877h3hf0jy.fsf@blp.benpfaff.org> |
| In reply to | #12613 |
"Mark" <mark_cruzNOTFORSPAM@hotmail.com> writes:
> 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
> ?
It's customary to put 'inline' at the beginning. GCC is
suggesting that you might have made a mistake. It's a warning,
not an error, so you can ignore it or turn it off if you prefer
to use an unusual ordering.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
[toc] | [prev] | [next] | [standalone]
| From | Kaz Kylheku <kaz@kylheku.com> |
|---|---|
| Date | 2011-11-03 20:10 +0000 |
| Message-ID | <20111103155816.965@kylheku.com> |
| In reply to | #12613 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-11-03 13:51 -0700 |
| Message-ID | <lnbostgca3.fsf@nuthaus.mib.org> |
| In reply to | #12613 |
"Mark" <mark_cruzNOTFORSPAM@hotmail.com> writes:
> "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 ?
C99 6.11.5 says:
The placement of a storage-class specifier other than at the
beginning of the declaration specifiers in a declaration is an
obsolescent feature.
This doesn't apply to function declarations, but I would think that the
placement of "inline" should be treated similarly.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web