Variable usage utility?

This is a discussion on Variable usage utility? within the C Programming forums, part of the General Programming Boards category; Searching for a program that can take a number of c files that form a project and perform certain analysis ...

  1. #1
    Enixia
    Guest

    Question Variable usage utility?

    Searching for a program that can take a number of c files that form a project and perform certain analysis on them. For example, to parse the files and produce the following:

    What variables (which includes structure/union members) are used, and where.
    What variables (which includes structure/union members) are unused.
    And also, which are assigned values, but the vales are not actually used.

    The program is expected to work on standard ANSI C programming files.

    Does such a program exist? The first part (which variables are used, and where) is partly provided by the compilers output of a map file, but from this it is difficult to obtain the second part, and also impossible to obtain the third.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Your compiler should be able to do some of that.

    Also, check out http://www.splint.org/
    and http://www.mkssoftware.com/docs/man1/ctags.1.asp


    >>also impossible to obtain the third
    My compiler warns of unused assignments:
    Code:
    #include <stdio.h>
    
    int main(void)
    {
      int i = 10;
      return(0);
    }
    
    
    /*
    Produces:
    
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    junk2.c:
    Warning W8004 junk2.c 7: 'i' is assigned a value that is never used in function main
    Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Enixia
    Guest
    Thanks for the links. My compiler does not give the warning message you describe, but it is for a specific application (Micro controller) and because of how much it cost, I really can't afford to change the compiler.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Enixia
    Thanks for the links. My compiler does not give the warning message you describe, but it is for a specific application (Micro controller) and because of how much it cost, I really can't afford to change the compiler.
    Just use your favourite text editor then. Serach for each variable by name, and see how many times it occurs. Not that hard. It would more than likely be faster than writing a program to do it for you.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 04:33 PM
  2. Global Variable Usage -- Failure in assignment
    By jake123 in forum C Programming
    Replies: 7
    Last Post: 02-15-2008, 02:30 PM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  4. Problem with a char variable set as a letter
    By 7smurfs in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2004, 01:25 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21