473,395 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

finding unused variable using c

i want to have a program written in c language which will find the unused variables of a c program. my INPUT will be a c file program will search for unused variables. without taking compiler program help.
Jul 19 '12 #1
2 2416
Banfa
9,065 Expert Mod 8TB
You would basically need to write a full syntactical and lexicon parser for the language to do this (i.e. a compiler with the final output of the compiled code) including preprocessing before you start.

If you really want to do this, as opposed to using your compiler warnings or getting a 3rd party application (such as PCLint) I suggest you start with something like YACC to build you syntax parser.
Jul 19 '12 #2
donbock
2,426 Expert 2GB
I assume unused variable means variables that are defined but not referenced.

A full syntactical and lexicon parser is a huge job. Are you sure you want to go there?

Does your compiler have any switches that cause it to print a symbol table? If so, you could parse the symbol table to find the unused variables.

There is no standard format for symbol tables so you will have to study the format produced by your compiler and then write a program customized to that format. It is a very good idea to comment your program to clearly identify the kind of symbol tables supported.
Jul 24 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: ralphNOSPAM | last post by:
Is there a PHP script that can find unused variables? I'd like to 'clean up' my scripts. Thanks...
0
by: Bill Smith | last post by:
If I have the line following in a stored proc... set rowCount = (select count(*) from t2); what is the equivalent way to set rowCount variable using dynamic sql... ... set sqlStmt = 'select...
6
by: Brian Haynes | last post by:
I've read all the posts in this forum that I can find that look related to this issue and I have only found 1 solution that I consider to be a bit of a hack. What I want to do is assign a value to...
10
by: Blaxer | last post by:
There is probably a really easy way to do this, so please forgive me but I would like to set the value of a variable from a variable, an example would be... function Calculate_Something(ByVal...
3
by: Tom McL. | last post by:
Is there a way I identify and remove unused variable within vb2005 standard edition
6
by: Rhino | last post by:
What's the simplest way to determine which, if any, of my selectors are not needed in a given stylesheet? I have a small number of HTML pages that share two stylesheets; one stylesheet is for...
7
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
3
by: jitender001001 | last post by:
hi all i m new to python and i have a problem of printing python variable using os.system() in bash !/usr/bin/env python var = "/home/anonymous" os.system("echo $var) it is not working..
1
by: unnikrishnan123 | last post by:
C# code for storing a selected date time value to a variable. using a DateTimePicker.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.