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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:28:40+00:00 2026-05-13T23:28:40+00:00

When I compile C code in recent version of gcc, I am getting the

  • 0

When I compile C code in recent version of gcc, I am getting the following warning:

Function is define but not used.

What can be the reason for this warning and how can I approach to resolve it?

  • 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-13T23:28:41+00:00Added an answer on May 13, 2026 at 11:28 pm

    As Giuseppe Guerrini mentioned, this is likely for a static function – you won’t see this warning on non-statics. The reason is that the compiler has to assume that a non-static function might be called from another compilation unit. however, a static function isn’t visible outside of the C file it’s in, so if it’s not used in that file, then it can’t be used at all.

    If find myself generally irritated by these warnings because:

    1. There are usually no negative side effects from having the function – even code space. Most linkers today will remove the code from the executable image if it’s not used.

    2. I often define a function in anticipation of it being used, and the warnings cause the build to, well, emit diagnostics. I prefer my builds to be warning-free, but in these cases I’d like the function to be compiled – ready to use when the next bit of work is gotten around to.

    3. I may have code that gets called only in debug builds, like in an assertion (or some conditionally compiled code). However, I’m not a huge fan of conditional compilation and like to reduce the use of #if statements to as few as possible. So my preference would be to have those functions not conditionally compiled even if they only get called in a particular configuration.

    As far as I’m concerned there’s little use to the warning, and it’s probably OK to turn them off if you like. (I’d like to hear opinions that might change my mind…)

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

Sidebar

Related Questions

I read from a book saying that the following c++ code should not compile:
When I run the following code, I keep getting this error: Traceback (most recent
I was a bit surprised when the following code wouldn't compile: -- Code 1
How can this code compile? The code below in the operator int CAN access
How can you compile the code using javac in a terminal by using google-collections
whenever I compile my code, I receive the following errors: error: constructor Player in
A (very long) while ago I regularly used the following code - then on
In python you can compile() string to be executed faster with exec(). But as
When I press F5 in Visual Studio 2010, my code does not compile anymore.
I'm getting a totally bizzare error trying to compile a C program using GCC.

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.