public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Inline functions
@ 1998-05-13 10:04 Michael Meissner
  1998-05-14  1:04 ` Hans Zuidam
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Meissner @ 1998-05-13 10:04 UTC (permalink / raw)
  To: hans, jbuck; +Cc: egcs, fray

| > Joe Buck wrote:
| > You aren't doing something like saying
| > 
| > inline int foo(int x);
| > 
| > in an .h file and then putting the definition of foo(int) in the .c file,
| > are you?
| RTEMS does something like this a lot ;-)  Is there a cpp define
| which allows one to find out the optimization level GCC is going
| to perform?  That could help eliminating those .h inline functions.

__OPTIMIZE__ is defined if any -Ox option is used other than -O0.
__OPTIMIZE_SIZE__ is defined if -Os is used.

--
Michael Meissner, Cygnus Solutions (Massachusetts office)
4th floor, 955 Massachusetts Avenue, Cambridge, MA 02139, USA
meissner@cygnus.com,	617-354-5416 (office),	617-354-7161 (fax)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inline functions
  1998-05-13 10:04 Inline functions Michael Meissner
@ 1998-05-14  1:04 ` Hans Zuidam
  0 siblings, 0 replies; 8+ messages in thread
From: Hans Zuidam @ 1998-05-14  1:04 UTC (permalink / raw)
  To: Michael Meissner; +Cc: egcs

> Michael Meissner wrote:
> __OPTIMIZE__ is defined if any -Ox option is used other than -O0.
> __OPTIMIZE_SIZE__ is defined if -Os is used.
Thanks!  Just after sending the question it struck me that I had
not looked at the cpp manual closely enough and had only read
through the gcc manual only ;-)

					Hans

-- 
H. Zuidam                        E-Mail: hans@brandinnovators.com
Brand Innovators B.V.            P-Mail: P.O. Box 1377
de Pinckart 54                   5602 BJ Eindhoven, The Netherlands
5674 CC Nuenen                   Tel. +31 40 2631134, Fax. +31 40 2831138

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inline functions
  1998-05-12 18:04 ` Joe Buck
  1998-05-13  1:47   ` Hans Zuidam
@ 1998-05-13  1:58   ` Akim Demaille
  1 sibling, 0 replies; 8+ messages in thread
From: Akim Demaille @ 1998-05-13  1:58 UTC (permalink / raw)
  To: Joe Buck; +Cc: Mark Hatle, egcs

>>>>> "Joe" == Joe Buck <jbuck@synopsys.com> writes:

Joe> You aren't doing something like saying

Joe> inline int foo(int x);

Joe> in an .h file and then putting the definition of foo(int) in the
Joe> .c file, are you?

Egcs/Gcc is kind enough to issue a warning when a static function is
prototyped, but not defined.  Couldn't a flag be added so that the
same rule applies to inline prototypes?  That would typically avoid
these problems.

Also, there are no warnings when only one of the proto and the of the
function is declared inline.  Is this on purpose?

Best regards,
	Akim

-- 
P-mail: Akim Demaille, 107 rue Bobillot, F-75013 Paris, France
E-mail: demaille@inf.enst.fr
V-mail: +33 1 45 81 78 68

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inline functions
  1998-05-12 18:04 ` Joe Buck
@ 1998-05-13  1:47   ` Hans Zuidam
  1998-05-13  1:58   ` Akim Demaille
  1 sibling, 0 replies; 8+ messages in thread
From: Hans Zuidam @ 1998-05-13  1:47 UTC (permalink / raw)
  To: Joe Buck; +Cc: fray, egcs

> Joe Buck wrote:
> You aren't doing something like saying
> 
> inline int foo(int x);
> 
> in an .h file and then putting the definition of foo(int) in the .c file,
> are you?
RTEMS does something like this a lot ;-)  Is there a cpp define
which allows one to find out the optimization level GCC is going
to perform?  That could help eliminating those .h inline functions.

Regards,
					Hans

-- 
H. Zuidam                        E-Mail: hans@brandinnovators.com
Brand Innovators B.V.            P-Mail: P.O. Box 1377
de Pinckart 54                   5602 BJ Eindhoven, The Netherlands
5674 CC Nuenen                   Tel. +31 40 2631134, Fax. +31 40 2831138

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inline functions
  1998-05-12 12:36 Mark Hatle
  1998-05-12 15:33 ` Richard Henderson
@ 1998-05-12 18:04 ` Joe Buck
  1998-05-13  1:47   ` Hans Zuidam
  1998-05-13  1:58   ` Akim Demaille
  1998-05-12 18:04 ` Jeffrey A Law
  2 siblings, 2 replies; 8+ messages in thread
From: Joe Buck @ 1998-05-12 18:04 UTC (permalink / raw)
  To: Mark Hatle; +Cc: egcs

> I am using the current egcs snapshot on a PPC machine running MkLinux.  I
> am trying to compile parts of the Linux server w/o an optimization level
> so that I can debug them line by line instead of the lines jumping all
> over.

Note that gcc will not do any inlining unless you're optimizing.  However

> When I compile without optimizations I get linking errors indicating that
> none of the inline functions were "compiled into" the object file

Now this part I don't understand (why you are getting linking errors).
Unless you're doing something tricky, I don't know why you aren't getting
static copies of inline functions.

You aren't doing something like saying

inline int foo(int x);

in an .h file and then putting the definition of foo(int) in the .c file,
are you?

> How can I compile selected files in the Linux server without optimization
> and still have the inline functions inline? 

You can't.  But ...

> (or at least compile as regular functions in that object file?)

This works for everyone else, so we need to figure out what you are doing
wrong.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inline functions
  1998-05-12 12:36 Mark Hatle
  1998-05-12 15:33 ` Richard Henderson
  1998-05-12 18:04 ` Joe Buck
@ 1998-05-12 18:04 ` Jeffrey A Law
  2 siblings, 0 replies; 8+ messages in thread
From: Jeffrey A Law @ 1998-05-12 18:04 UTC (permalink / raw)
  To: Mark Hatle; +Cc: egcs

  In message < Pine.LNX.3.95.980512121158.12719B-100000@EEL2.cs.mankato.msus.edu
  > How can I compile selected files in the Linux server without optimization
  > and still have the inline functions inline? (or at least compile as
  > regular functions in that object file?)
inlining is only performed when optimizing.

You need to declare the functions as static inline like this example
so that you'll get a copy of the function when not optimizing:

int z;

static inline x (int y) { z = y; }

foo()
{
x (5);
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inline functions
  1998-05-12 12:36 Mark Hatle
@ 1998-05-12 15:33 ` Richard Henderson
  1998-05-12 18:04 ` Joe Buck
  1998-05-12 18:04 ` Jeffrey A Law
  2 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 1998-05-12 15:33 UTC (permalink / raw)
  To: Mark Hatle; +Cc: egcs

On Tue, May 12, 1998 at 12:15:28PM -0500, Mark Hatle wrote:
> When I compile without optimizations I get linking errors indicating that
> none of the inline functions were "compiled into" the object file then I
> removed the "-O2" from... I have also tried -O, -O0, -O1 and they produce
> the same results.  One advice from someone, I tried to add
> -fkeep-inline-functions and got the same outcome.

This is primarily due to the is the effect of `extern inline'
seen throughout the Linux kernel sources.

Though -O1 should have worked... I wonder what's up with that.

> How can I compile selected files in the Linux server without optimization
> and still have the inline functions inline? (or at least compile as
> regular functions in that object file?)

You can't. 

Your best option is to change problematic ocurrences of
`extern inline' to `static inline'.


r~

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Inline functions
@ 1998-05-12 12:36 Mark Hatle
  1998-05-12 15:33 ` Richard Henderson
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mark Hatle @ 1998-05-12 12:36 UTC (permalink / raw)
  To: egcs

Forgive me if this comes up a lot, but I didn't see it on a quick glance
though the mailing list archives.  This is the problem I am having:

I am using the current egcs snapshot on a PPC machine running MkLinux.  I
am trying to compile parts of the Linux server w/o an optimization level
so that I can debug them line by line instead of the lines jumping all
over.

When I compile without optimizations I get linking errors indicating that
none of the inline functions were "compiled into" the object file then I
removed the "-O2" from... I have also tried -O, -O0, -O1 and they produce
the same results.  One advice from someone, I tried to add
-fkeep-inline-functions and got the same outcome.

How can I compile selected files in the Linux server without optimization
and still have the inline functions inline? (or at least compile as
regular functions in that object file?)

--Mark


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1998-05-14  1:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-05-13 10:04 Inline functions Michael Meissner
1998-05-14  1:04 ` Hans Zuidam
  -- strict thread matches above, loose matches on Subject: below --
1998-05-12 12:36 Mark Hatle
1998-05-12 15:33 ` Richard Henderson
1998-05-12 18:04 ` Joe Buck
1998-05-13  1:47   ` Hans Zuidam
1998-05-13  1:58   ` Akim Demaille
1998-05-12 18:04 ` Jeffrey A Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).