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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:34:49+00:00 2026-06-07T22:34:49+00:00

I came across a question regarding writing a code to determine unused functions in

  • 0

I came across a question regarding writing a code to determine unused functions in C++. We can use different data structures to determine unused functions. But before that, we need to parse the code. I have question related to parsing part, how we can differentiate functions declaration and definition and function-calls?

Like,

 //function declaration without argument
 fun1 ();

 //function definition
 fun1 () {
   // code goes here
  }

 main () {
   fun1 ();
  }

Above declaration and call is looks same where as definition part is little bit different from declaration and call.

Other than above scenario, there are multiple scenario for calling a function and functions scope, like two classes having function with same name one function get called within member function (i.e. no explicit calling object required) OR function call using object so, need to understand object’s type first to determine which function is actually called.

How can parsing implemented efficiently? How many parsing will required in above scenario?

  • 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-07T22:34:51+00:00Added an answer on June 7, 2026 at 10:34 pm

    This is how you can distinguish them:

    //function definition
    return_type fun1 (args) {
      // code goes here
    }
    

    Note that function definition has a “return type” before the function name.

    Also, note that a function declaration looks exactly the same as its definition. You don’t actually need to distinguish them until you see either ; or {. That is the point in which you make the decision whether its a declaration or definition. In your particular application, you don’t really care about it because you don’t care what the function actually does.

    Unfortunately for you, C++ is complicated. To determine which functions are useless, you actually need at least a basic semantic analysis. This includes at least the type system.

    What is worse, is that some function may not necessarily be called directly, but through a virtual function. So your static analysis of the code shows only the parent’s function getting called, while in reality it’s the child’s.

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

Sidebar

Related Questions

I have a question regarding the following code snippet I came across in one
I have a question regarding Twitter API. I came across something called Parameters and
I came across this question: say given two weights 1 and 3, u can
I came across this question on an interview questions thread. Here is the question:
I came across this question after searching for a ODBC or JDBC. To my
I came across this question on transcender: What should you apply to a field
I came across this question on a website. As mentioned there, it was asked
I came across a question recently that was for Generating primary key in a
Hi I came across the question in Test your skills in c++. Please let
I came across some code today that surprised me. A variable was defined (outside

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.