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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:03:33+00:00 2026-06-13T11:03:33+00:00

I read recently several recursive functions which were declared static . Does adding static

  • 0

I read recently several recursive functions which were declared static.

Does adding static in front of functions declarations help GCC to optimize tail-recursive function? Is this mandatory to get optimizations?

  • 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-13T11:03:34+00:00Added an answer on June 13, 2026 at 11:03 am

    I don’t see any reason why a function being static should help the compiler optimize recursive calls in particular.

    Immediately, it sounds more likely that the recursive functions you have seen were simply internal to the compilation unit. A recursive function will often need a richer interface than one wants to expose to the rest of the program — for example there might be extra parameters that are only used by the recursive calls, or the return value from a general call may need to be adjusted in order to fit with the abstraction one wants to present to the rest of the code. Therefore it is usual to write a wrapper function that sets default values for the extra parameters and in general adjusts the interface of the recursive function to something nice that makes sense externally.

    Now since the recursive function is only called by itself and the wrapper function, it is natural to declare it static — not because of the recursion itself, but in order to prevent polluting the global namespace with it. It is also possible that the compiler can use more efficient calling conventions (adapted to that particular function body) for static functions, because it knows all of the call sites and does not have to follow an ABI that will let separately compiled code call it.

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

Sidebar

Related Questions

I recently read about using GCC's code generation features (specifically, the -finstrument-functions compiler flag)
I recently read a question on here about static and dynamic linking, which reminded
I recently read how to disable scripting for an entire application by adding the
I've read recently that iOS is message based. Is that similar to an event-based
I recently read an article about password hashing . How are MD5 or SHA1
I recently read a blog in Nodejitsu and I am wondering how this piece
I recently read a post online about rotating text with css. This appealed to
I recently read the the following SO question. What's the best way to store
I recently read the following overflow post: Hidden Features of C# One of the
I recently read through Code Complete, and it recommends that I create a project

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.