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

  • Home
  • SEARCH
  • 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 563367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:39:10+00:00 2026-05-13T12:39:10+00:00

If a header file contains a function definition it can be inlined by the

  • 0

If a header file contains a function definition it can be inlined by the compiler. If the function is exported, the function’s name and implementation must also be made available to clients during linkage. How does a compiler achieve this? Does it both inline the function and provide an implementation for external callers?

Consider Foo.h:

class Foo
{
    int bar() { return 1; }
};

Foo::bar may be inlined or not in library foo.so. If another piece of code includes Foo.h does it always create its own copy of Foo::bar, whether inlined or not?

  • 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-13T12:39:10+00:00Added an answer on May 13, 2026 at 12:39 pm

    Header files are just copy-pasted into the source file — that’s all #include does. A function is only inline if declared using that keyword or if defined inside the class definition, and inline is only a hint; it doesn’t force the compiler to produce different code or prohibit you from doing anything you could otherwise do.

    You can still take the address of an inline function, or equivalently, as you mention, export it. For those uses, the compiler simply treats it as non-inline and uses a One Definition Rule (the rule which says the user can’t apply two definitions to the same function, class, etc) to “ensure” the function is defined once and only one copy is exported. Normally you are only allowed to have one definition among all sources; an inline function must have one definition which is repeated exactly in each source it is used.

    Here is what the standard has to say about inline extern functions (7.1.2/4):

    An inline function shall be defined in
    every translation unit in which it is
    used and shall have exactly the same
    definition in every case (3.2). [Note:
    a call to the inline function may be
    encountered before its defi- nition
    appears in the translation unit. ] If
    a function with external linkage is
    declared inline in one transla- tion
    unit, it shall be declared inline in
    all translation units in which it
    appears; no diagnostic is required. An
    inline function with external linkage
    shall have the same address in all
    translation units. A static local
    variable in an extern inline function
    always refers to the same object. A
    string literal in an extern inline
    function is the same object in
    different translation units.

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

Sidebar

Ask A Question

Stats

  • Questions 266k
  • Answers 266k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer $(document).ready(function() { var refreshId = setInterval(function() { $('#main').fadeOut("slow").load('Default.aspx').fadeIn("slow"); }, 50000);… May 13, 2026 at 12:39 pm
  • Editorial Team
    Editorial Team added an answer Did you mean you created a COM callable wrapper around… May 13, 2026 at 12:39 pm
  • Editorial Team
    Editorial Team added an answer Take a look at the LaTeX ifplatform package. There was… May 13, 2026 at 12:39 pm

Related Questions

I currently have a program where my main code is in a file main.cpp.
I have some quick questions on windows dll. Basically I am using the ifdefs
I am experiencing Frustration ^ Frustraion with this %&$^& VS IDE. I am using
I have a closed source unmanaged DLL coded in C++ that I wanted to
I have a function that exports a table into a CSV file, then I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.