4 Replies - 476 Views - Last Post: 22 January 2012 - 02:47 PM Rate Topic: -----

#1 hulla  Icon User is offline

  • Writing Lines


Reputation: 49
  • View blog
  • Posts: 732
  • Joined: 05-March 11

Diff between "inline" before and after return type in function

Posted 21 January 2012 - 08:25 PM

Sorry for text speak in the title. I couldn't fit it all in properly.

Is there a difference in these?:

inline void foo();


and

void inline foo();


I have a feeling there isn't but I'd like to be sure and which one has become programming convention.

Thanks.
Is This A Good Question/Topic? 0
  • +

Replies To: Diff between "inline" before and after return type in function

#2 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Diff between "inline" before and after return type in function

Posted 21 January 2012 - 08:52 PM

No difference. It's just more awkward to interpolate between the type and specifiers like inline.
Was This Post Helpful? 1
  • +
  • -

#3 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2982
  • View blog
  • Posts: 10,299
  • Joined: 08-August 08

Re: Diff between "inline" before and after return type in function

Posted 21 January 2012 - 09:25 PM

Note that your compiler isn't required to honor a request to make a function inline, and doing so doesn't necessarily give you a speed advantage. In fact it can sometimes slow things down and use extra memory.
Was This Post Helpful? 1
  • +
  • -

#4 Mrk  Icon User is offline

  • D.I.C Head

Reputation: 29
  • View blog
  • Posts: 66
  • Joined: 03-December 09

Re: Diff between "inline" before and after return type in function

Posted 22 January 2012 - 02:38 PM

View PostCTphpnwb, on 21 January 2012 - 09:25 PM, said:

Note that your compiler isn't required to honor a request to make a function inline, and doing so doesn't necessarily give you a speed advantage. In fact it can sometimes slow things down and use extra memory.


But if I turn off all optimizations on my compiler in the settings, then it will compile inline for sure, right?
Was This Post Helpful? 0
  • +
  • -

#5 jimblumberg  Icon User is online

  • member icon


Reputation: 4063
  • View blog
  • Posts: 12,545
  • Joined: 25-December 09

Re: Diff between "inline" before and after return type in function

Posted 22 January 2012 - 02:47 PM

Not necessarily. The inline specifier is only a hint to the compiler, the compiler may ignore this hint. See this link Inline functions.

Jim
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1