Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7653641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:04:32+00:00 2026-05-31T12:04:32+00:00

If I don’t declare a function f as inlined. Just as follows: A.h: X

  • 0

If I don’t declare a function f as inlined. Just as follows:

A.h:

X f(Y y);

A.cpp:

X f(Y y)
{
    ...
}

Then in a different translation unit:

B.cpp:

#include "A.h"

Z g(W w)
{
    ...
    ... f(...) ...
    ...
}

Then I compile the two translation units A.o and B.o with gcc 4.6, and then link them also through gcc. (Maybe with -O3 to both steps)

Will gcc consider inlining the function for performance at link time? Or is it too late?

In a code review someone suggested that I shouldn’t declare my functions as inline as the compiler knows better than I do when to inline. I was always under the impression unless the function is defined in the header than the compiler doesn’t have the option to inline it.

(If the answer differs for C mode, C++ mode, or gnu++0x mode please point this out also)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:04:32+00:00Added an answer on May 31, 2026 at 12:04 pm

    The feature is called Link Time Optimization(LTO) and is not enabled by default in GCC 4.6

    [edit]
    With LTO enabled, GCC will save a “GIMPLE” representation of X f(Y y) in A.obj. This representation is slightly more processed than the usual C++ pre-processing, but not a lot. In particular, it’s not translated into assembly yet. As a result, the linker can still inline it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't these two mean the same thing, first get the value and then increment?
Don't be scared of the extensive code. The problem is general. I just provided
Don't be frightened, its a very basic code. Just wanted to check with you
Don't have much to say, just can get into the event handler. XAML: <Grid>
Don't know if this is an eclipse specific problem but whenever I declare a
Don't know whether I'm having a "thick day" - but I just wondered what
Don't freak out about the length of my post, it's pretty simple, I just
Don't understand why #include <Header.h> is not compiling while #include Header.h is compiling with
Don't need to go so far, just install Devexpress 11.2.5 and run the GridDemo(
Don't you hate it when you have class Foobar { public: Something& getSomething(int index)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.