Topic: forcing inline ?


Author: Michiel.Salters@tomtom.com
Date: Wed, 8 Feb 2006 13:33:55 CST
Raw View
John Nagle wrote:

>     Properly, "forcing inline" is a hint to the implementation,
> and should be expressed with a pragma.
>
>        John Nagle

That's slightly tricky, as #pragma's and templates do not exactly play
nice.
I do think it's possible, but I haven't got a very clear idea about how
to do so.
Do you? Does it cover place of definition/place of instantiation and
specializations?

Regards,
Michiel Salters

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: francis@robinton.demon.co.uk (Francis Glassborow)
Date: Mon, 16 Jan 2006 00:06:58 GMT
Raw View
In article <11simvfnje9sq6f@corp.supernews.com>, Bart van Ingen Schenau
<bart@ingen.ddns.info> writes
>> How to create such a 'keyword' ?
>
>You ask the compiler writers *very* nicely. If you ask nicely enough (or
>pay enough money to them), a future version of the compiler may include
>the 'keyword' that you requested.
>Note that any code that uses this new 'keyword' is essentially locked to
>one particular version of one particular compiler.

Or you modify G++ for yourself:-) But I really would advise against
using extensions, particularly those that involve added keywords.

--
Francis Glassborow      ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: dagecko@free.fr (dagecko)
Date: Mon, 16 Jan 2006 00:07:34 GMT
Raw View
Le Sun, 15 Jan 2006 06:21:37 +0000, Roger Orr a =E9crit=A0:

> This is a compiler specific keyword (hence the leading double underscor=
e).

Okay. I didn't knew that double underscore is for compiler specific stuff=
s.
Who recommand this ?

> I know Microsoft defines this keyword, with the following caveat from M=
SDN:
>=20
> "The __forceinline keyword overrides the cost/benefit analysis and reli=
es on
> the judgement of the programmer instead. Exercise caution when using
> __forceinline. Indiscriminate use of __forceinline can result in larger=
 code
> with only marginal performance gains or, in some cases, even performanc=
e
> losses (due to increased paging of a larger executable, for example). "
>=20
> In general I would recommend using 'inline' - the standard C++ keyword.

Yes of course. I was just a bit curious about that.

>=20
> Hope this helps,

This helped.

> Roger Orr


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: rogero@howzatt.demon.co.uk ("Roger Orr")
Date: Tue, 17 Jan 2006 04:30:16 GMT
Raw View
"dagecko" <dagecko@free.fr> wrote in message
news:pan.2006.01.15.11.53.38.988771@free.fr...
Le Sun, 15 Jan 2006 06:21:37 +0000, Roger Orr a =E9crit :

> This is a compiler specific keyword (hence the leading double underscor=
e).

Okay. I didn't knew that double underscore is for compiler specific stuff=
s.
Who recommand this ?

>From the C++ standard

[17.4.3.1.2 Global names]

"Each name that contains a double underscore (_ _) or begins with an
underscore followed by an uppercase
letter (2.11) is reserved to the implementation for any use."

Roger Orr
--
MVP in C++ at www.brainbench.com


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: nagle@animats.com (John Nagle)
Date: Wed, 18 Jan 2006 03:54:37 GMT
Raw View
Roger Orr wrote:
> "dagecko" <dagecko@free.fr> wrote in message
> news:pan.2006.01.15.11.53.38.988771@free.fr...
> Le Sun, 15 Jan 2006 06:21:37 +0000, Roger Orr a =EF=BF=BDcrit :
>=20
>=20
>>This is a compiler specific keyword (hence the leading double underscor=
e).
> Okay. I didn't knew that double underscore is for compiler specific stu=
ffs.
> Who recommand this ?
>=20
>>From the C++ standard
>=20
> [17.4.3.1.2 Global names]
>=20
> "Each name that contains a double underscore (_ _) or begins with an
> underscore followed by an uppercase
> letter (2.11) is reserved to the implementation for any use."

    I thought that meant that the double underscore was for
IMPLEMENTATION GENERATED symbols, not ones written by the user.
Adding a nonstandard keyword makes the source code unparseable by
a standard C++ parser.  (This may be viewed as a bug or
a feature, depending upon your market position.)

    Properly, "forcing inline" is a hint to the implementation,
and should be expressed with a pragma.

       John Nagle

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: kuyper@wizard.net
Date: Wed, 18 Jan 2006 10:35:18 CST
Raw View
John Nagle wrote:
> Roger Orr wrote:
> > "dagecko" <dagecko@free.fr> wrote in message
> > news:pan.2006.01.15.11.53.38.988771@free.fr...
> > Le Sun, 15 Jan 2006 06:21:37 +0000, Roger Orr a ?crit :
> >
> >
> >>This is a compiler specific keyword (hence the leading double underscore).
> > Okay. I didn't knew that double underscore is for compiler specific stuffs.
> > Who recommand this ?
> >
> >>From the C++ standard
> >
> > [17.4.3.1.2 Global names]
> >
> > "Each name that contains a double underscore (_ _) or begins with an
> > underscore followed by an uppercase
> > letter (2.11) is reserved to the implementation for any use."
>
>     I thought that meant that the double underscore was for
> IMPLEMENTATION GENERATED symbols, not ones written by the user.
> Adding a nonstandard keyword makes the source code unparseable by
> a standard C++ parser.

A standard C++ parser had better correctly parse it as an identifier.
At a later stage in the process, that identifier will be identified as
not being a standard-defined keyword, and not being a name defined in
the standard library. Therefore, because of the above-quoted section,
the double underscore makes it an identifier reserved to the
implementation. But it's still an identifier, and should be parsed as
such.

An implementation can do whatever it wants with code that uses such
identifiers, but the most common behavior I've seen is to handle them
like any other identifier. The fact that they're dangerous to use isn't
because they interfere with parsing or translation. It comes from the
fact that the above-quoted clause makes it legal for implementors can
to use such identifiers for their own purposes, which might interfere
with the way you are using them. However, if you happen to choose an
identifier reserved to the implementation, but not currently in use by
the implementation, you can generally get away with using that
identifier.

Non-standard extensions of any kind  make the code unportable to
implementations that don't support the extension. That's not a problem
for code that doesn't need to be portable, and a lot of code is so
heavily tied into a specific context that there's no point in writing
it to be portable to a different context. Also, non-standard extensions
are the mechanism that allows the creation of test beds for proposed
new features for eventual standardization.

>     Properly, "forcing inline" is a hint to the implementation,
> and should be expressed with a pragma.

It certainly could be implemented using a pragma, but a pragma can be
inserted anywhere. There's an advantage to defining it as a
implementation-specific keyword: that keyword can be inserted in an
implementation-specific extension to the standard C++ grammar, such
that it was legal to use this keyword only as part of the declaration
of a function, producing a diagnostic anywhere else. Of course, the
compiler could impose the same restriction on the pragma, but doing so
would be less consistent with the style of the standard C++ grammar.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: dagecko@free.fr (dagecko)
Date: Sat, 14 Jan 2006 16:00:18 GMT
Raw View
Hi,

I've seen a program that uses __forceinline for some functions
but I wasn't able to see its declaration inside that program.

Is it declared in the stdlib ?

If not, what should I expect such a thing to do ? What results ?
How to create such a 'keyword' ?

thank you

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: Bart van Ingen Schenau <bart@ingen.ddns.info>
Date: Sat, 14 Jan 2006 19:15:13 CST
Raw View
dagecko wrote:

>
> Hi,
>
> I've seen a program that uses __forceinline for some functions
> but I wasn't able to see its declaration inside that program.
>
> Is it declared in the stdlib ?

No, it is a non-standard extention.

>
> If not, what should I expect such a thing to do ? What results ?

<OT>
It tells the compiler that you want to have that function inlined, no
matter what the costs are.
</OT>
To get a definitive answer of what a particular compiler extension does,
you should ask in a group that is dedicated to that compiler.

> How to create such a 'keyword' ?

You ask the compiler writers *very* nicely. If you ask nicely enough (or
pay enough money to them), a future version of the compiler may include
the 'keyword' that you requested.
Note that any code that uses this new 'keyword' is essentially locked to
one particular version of one particular compiler.

>
> thank you
>
Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://www.eskimo.com/~scs/C-faq/top.html
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: rogero@howzatt.demon.co.uk ("Roger Orr")
Date: Sun, 15 Jan 2006 06:21:37 GMT
Raw View
"dagecko" <dagecko@free.fr> wrote in message
news:pan.2006.01.14.10.54.55.331383@free.fr...
>
> Hi,
>
> I've seen a program that uses __forceinline for some functions
> but I wasn't able to see its declaration inside that program.
>

This is a compiler specific keyword (hence the leading double underscore).
I know Microsoft defines this keyword, with the following caveat from MSDN:

"The __forceinline keyword overrides the cost/benefit analysis and relies on
the judgement of the programmer instead. Exercise caution when using
__forceinline. Indiscriminate use of __forceinline can result in larger code
with only marginal performance gains or, in some cases, even performance
losses (due to increased paging of a larger executable, for example). "

In general I would recommend using 'inline' - the standard C++ keyword.

Hope this helps,
Roger Orr
--
MVP in C++ at www.brainbench.com


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]