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 7775603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:40:26+00:00 2026-06-01T17:40:26+00:00

I am studying macros and found many sources and questions regarding difference between macros

  • 0

I am studying macros and found many sources and questions regarding difference between macros and inline functions. But there is nothing which concretely specifies and differentiates pros&cons of inline vs normal functions.

But what about if I want to select between normal function and inline function?

I know that use of inline function increase the code size. But as while studying size is not the primary issue , efficiency is the goal. Making a function an inline function suggests that calls to the function be as fast as possible.(Due to stack and stuff overhead)

Is always using inline function is better or not? If not then WHY? What are the benefits of using normal functions over inline?

While reading other questions I read that inline is only a hint to compiler. Compiler may ignore it. When does compiler ignore it and WHY?

  • 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-06-01T17:40:27+00:00Added an answer on June 1, 2026 at 5:40 pm

    Inlining a function can have several advantages:

    1. It can make the program size smaller. This is typically the case when a function is only used once. Also, see 2. and 3.

    2. The compiler can eliminate unused bits of the function, if the compiler knows that a variable is constant, or non-NULL, or something like that. This can save size, but also makes the code more efficient at run time.

    3. The compiler can eliminate bits of the calling function, or even other inlined functions because it can see what the function does with/to the data. (Say the code checks the return value and calls an error function if it’s NULL, it might be able to rule that out.

    4. It can reduce the call overhead, but in current processors with predictive branching that’s not as much of a win as you might think.

    5. It can hoist constant bit out of loops, do common subexpression elimination, and many other optimizations to make looping code more efficient, and such like.

    And then there’s the disadvantages:

    1. It can make the code larger, obviously.

    2. It can increase register pressure within the calling function which might confuse the compiler and prevent it optimizing as well.

    3. Having one hot function that can live in the CPU cache can be quicker than duplicating it to many places that are not always cached.

    4. It can hamper debugging.

    The reason that the inline function is just a hint is mostly because the C standard does not require that the compiler optimize anything at all. If it wasn’t a hint then optimization wouldn’t be optional. Also, just because the function isn’t marked inline doesn’t stop the compiler inlining it if it calculates that doing so would be advantageous.

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

Sidebar

Related Questions

i studying TDateTime functions and procedure, but not found something that allow me to
After studying TCP/UDP difference all week, I just can't decide which to use. I
Im studying inline functions in C++ and have come to a section concerning limitations
I was just studying OCPJP questions and I found this strange code: public static
Studying the K&R book in C I had a few questions regarding complicated pointer
Studying C#, my books are showing me classes for readin files. I've found 2
Since I started studying object-oriented programming, I frequently read articles/blogs saying functions are better,
I started studying POSIX timers, so I started also doing some exercises, but I
While studying C# in ASP.net I have trouble understanding several classes. In which scenario
I am studying an existing Perl program, which includes the following line of code:

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.