Hi - Is there a way to make gcc compilation fail or how can I write a script to check that double types are not being used in the C code?
How to check that a type double is not being used in the code.
Collapse
X
-
Tags: None
-
Write code to read the source code and scan for the word double. You will need to record the include file names and search those as well. -
That is a beautiful idea - how in C does one scan an entire set of 500 files for one keyword. And then...how can I turn the results into a "warning" ?
thank youComment
-
Your scanning code becomes a pre-condition for the build. That is, launch your gcc build from the scan code. That way you can produce warnings from your code before doing the gcc build.
I expect there are gcc tools in place already. That is, Visual Studio.NET has a pre-condition and a post-condittion for its project builds where the pre-condition steps are executed before the build and the post-condition steps after the build. The project user just clicks "build" as usual and these additional steps become part of the overall build process for that project.
As to scanning 500 files, I would put those filenames in a disc file and direct the scan code to scan every file whose filename is in that file. If you are using hand-written make files, you could first scan the make file for the files to be compiled and scan those.
Further, you could have a second file of keywords so the scan code can search for many keywords as once. I might even add a qualifier for must be absent and one for must be present.
In effect you are writing your own pre-processor. This is exactly what Oracle does with their pro*C. You put Oracle keywords in your code and this scanner comes along and changes those keyowrds to the actual C code that needs to be there. That expanded file is then the one sent to the C pre-processor, which further expands the C macros and passes the thing along to the compiler. That way you can connect to an Oracle database without needing to know anything about how to do that. You just use the pro*C word instead.Comment
-
Comment