Tuesday, July 14, 2009

How to I make a tool for Modifying C/C++ Source code to remove a global variable of interest ?

I need to remove specified global variable from C/C++ souce code. For this i need to make a tool. I dont know much about C so I am looking towards making the tool using java. Could someone help me out with how i can do this. I know that once the specified variable is removed it will destroy the functionality of the original source code but the functionality is of no interest to me. I just need all occurances of the specified variable to be ripped and thrown out from the source code while keeping as much of the original code intact as possible. NOTE : after this the source code must still be compilable although the functionality will not work.

How to I make a tool for Modifying C/C++ Source code to remove a global variable of interest ?
Won't work in most cases. You'll have to remove entire lines of code to make this correct. if(x == 4) { printf("%d\n", x); will break if you remove the variable x. This will break the functionality and the code.





If you are going to replace it with another variable, then it will still work, but if not, I don't see why you are wanting to do this.
Reply:Many programs (Visual Studio, Notepad, Dev-C++) have a feature to find and replace text in a document/project. This can usually be found by going to Edit -%26gt; Find and Replace, where you can then simply enter the variable you wish to replace and leave the "Replace with" line blank to remove all occurrences of that variable.

online florists

No comments:

Post a Comment