Below is a small code segment in the python script I wrote. The purpose of the script is to compile various C files. (I modified the segment and simplified it to fit the purpose of the question.)
fileName = "somefile.c" my_cmd = "gcc -std=c99 -Wall " + fileName[-2:0] + " .o " + fileName os.system(my_cmd)
This works well. But I want to keep track of which file got compiled without warnings and which file showed warnings.
To check if the file compiled successfully is not a problem. I can either check the return value of os.system() or I can check if the corresponding object file got created or not.
But how can I check if the somefile.c had any warnings during compilation? Thanks!
What I have tried:
I tried using the ">" operator (redirection) but that is not working. I used something like:
os.system(my_cmd + " > output")
No matter what the contents of somefile.c are, the file named output is always created and is empty!!