Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts

    Tool to determine include file usage

    Let's say you have a c file containing 10,000 lines of code and it has 15 include files. It would be too difficult to go through every function of every include file to determine if the include file is actually needed. Surely there is some tool that can parse the C file and headers and determine if the header is actually being used?
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #2
    New Coder mentalhorse's Avatar
    Join Date
    Jul 2005
    Location
    Duanesburg, NY
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Last edited by mentalhorse; 07-03-2007 at 10:40 PM. Reason: Found a program.
    Why is a raven like a writing desk?

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Thanks. That is along the lines of what I am looking for. I've determined now though that I also really need to see what functions/data are specifically being used from those included files also rather than just if they are being used. I am redesigning a large portion of some software that other parts are dependent on so along with seeing which files are depending upon this I need to also see what functions/data they are using.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #4
    New Coder mentalhorse's Avatar
    Join Date
    Jul 2005
    Location
    Duanesburg, NY
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I guess you could comment out the '#include' line and if there are not compile errors than it isn't needed. This would work right?
    Why is a raven like a writing desk?

  • #5
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,064
    Thanks
    0
    Thanked 15 Times in 15 Posts
    Technically he could but what would that solve? Many headers are used as includes for other headers and just simply disabling one won't show whether a function is depended upon the specific header you disabled/commented...

    What Spookster is really looking for is a plug-in or program, that can monitor another program at runtime do determine what functions are being used from whichever headers. At the completion of the run-time event, this plug-in would generate some sort of report that shows which functions and headers were used and which were not.

    Natively many compilers will show you whether a variable is referenced or used, but not functions or headers.

    This might be a good pet project Spookitha...

    -sage-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Well you could even write a program that would just check to see if the function is ever called in the source code. It wouldn't necessarily have to monitor the program execution.
    OracleGuy

  • #7
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    That's exactly what I need. Might be a neat tool to come up with.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #8
    New Coder mentalhorse's Avatar
    Join Date
    Jul 2005
    Location
    Duanesburg, NY
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Or just put breakpoints on all the functions. But I wouldn't know how to make the programs mentioned so that's what I would do.
    Why is a raven like a writing desk?

  • #9
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by Spookster View Post
    That's exactly what I need. Might be a neat tool to come up with.
    That it would, though I've heard C++ is one of the harder languages to parse since it isn't context free. However I guess you wouldn't need to care about the stuff in the functions except for function calls and you wouldn't be trying to validate the syntax so that wouldn't matter. Now I wonder if some well crafted regular expressions could do it... I might have to play around with that later.
    OracleGuy

  • #10
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,064
    Thanks
    0
    Thanked 15 Times in 15 Posts
    Quote Originally Posted by oracleguy View Post
    That it would, though I've heard C++ is one of the harder languages to parse since it isn't context free. However I guess you wouldn't need to care about the stuff in the functions except for function calls and you wouldn't be trying to validate the syntax so that wouldn't matter. Now I wonder if some well crafted regular expressions could do it... I might have to play around with that later.
    Be worth putting our heads together to do something worthwhile????

    -saige-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •