1 Goals
1. To learn about options supported by the gcc / g++ / clang / clang++ compilers.
2. To explore some useful compiler options.
2 The commands to use with the instructions below.
1a. cc –version badCode.c
1b. c++ –version badCode.cpp
2a. c++ -Wall -O3 -o badCode_O3 badCode.cpp
2b. c++ -w badCode.cpp (Inhibit all warning messages.)
3a. cc -Wall -O0 badCode.c (This is an upper case o followed by a zero.)
3b. c++ -Wall -O3 badCode.cpp (O1 and O2 also exist.)
4a. cc badCode.c
4b. c++ badCode.cpp
5a. cc -S -Wall -O0 -o badCode_O0.s badCode.c (Compile only, )
5b. cc -S -Wall -O3 -o badCode_O3.s badCode.c ( stop before calling assembler.)
6a. cc -E -o badCode_cE badCode.c
6b. c++ -E -o badCode_cppE badCode.cpp
3 Instructions
The programs. To do this assignment, you need a very short C program (badCode.c) and a
comparable C++ program (badCode.cpp). Make a new folder called P3 and put copies of these
two programs in it. Open a text file in this directory into which you can paste all sorts of answers.
Please do not use Word! Word destroys this kind of text.
1. Execute commands 1a and 1b. Copy the output into the text file. What compilers are being
used on your system?
2. Execute commands 2a and 2b. Describe the differences in the screen output. Which one
would you rather see when you compile?
3. Execute commands 3a and 3b. Describe the difference between all warnings and no warnings.
Correct all of the warnings you see. Call your corrected files goodCode.c and goodCode.cpp.
Submit the code as part of your homework.
4. Execute command 4a. You know that these programs make warnings. Nonetheless, they also
produce executable code. What is the name of the executable file? Execute it and paste the
output into your text file. Now do the same for command 4b.
5. Execute commands 5a and 5b. The -S flag stops compilation after code generation and before
assembly. Compare the two files produced with different levels of optimization. What was
eliminated by optimizing?
6. Execute commands 6a and 6b. The -E flag stops compilation after preprocessing and before
parsing begins. Describe what the preprocessor does. Comment on the difference between
the results of preprocessing these small similar programs written in C and in C++.
4 Submission Instructions
Remove all executable files from your directory, and remove the two little programs I sent you. Zip
the rest and send it to me. This is due September 19.
4547, 6647, Compiler, CSCI, Options, Project, solved
[SOLVED] Csci 4547 / 6647 project 3: compiler options
$25
File Name: Csci_4547___6647_project_3__compiler_options.zip
File Size: 414.48 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.