guides:software:gcc:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
guides:software:gcc:start [2020/07/19 14:33] – [Producing Additional Warnings] wikiadmin | guides:software:gcc:start [2024/07/25 15:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 160: | Line 160: | ||
==== Some Useful Arguments ==== | ==== Some Useful Arguments ==== | ||
- | * // | + | * //- -version// will display the version of g++ you are using. |
* < | * < | ||
$ g++ --version | $ g++ --version | ||
Line 218: | Line 218: | ||
Compilers are also capable of analyzing source code to predict where this code may cause run time errors. | Compilers are also capable of analyzing source code to predict where this code may cause run time errors. | ||
- | Your instructor may require one or more of the following flags when compiling code | + | Your instructor may require one or more of the following flags when compiling code: |
* // | * // | ||
Line 238: | Line 238: | ||
* // | * // | ||
* Warn when an implicit conversion may change a value. | * Warn when an implicit conversion may change a value. | ||
+ | |||
+ | Note: There are **many** other warning producing flags. | ||
For the following code: | For the following code: | ||
Line 246: | Line 248: | ||
int main() { | int main() { | ||
+ | int a,b; | ||
+ | int c; | ||
- | | + | if (a = b) |
- | int b; | + | cout << " a is 4" |
- | + | ||
- | | + | |
- | cout << " a is 4"; | + | |
a = 5; | a = 5; | ||
Line 263: | Line 264: | ||
$ g++ -g -O3 -Wpedantic -Wall -Wextra -Wmisleading-indentation -Wunused -Wuninitialized -Wshadow -Wconversion bad.cpp | $ g++ -g -O3 -Wpedantic -Wall -Wextra -Wmisleading-indentation -Wunused -Wuninitialized -Wshadow -Wconversion bad.cpp | ||
bad.cpp: In function 'int main()': | bad.cpp: In function 'int main()': | ||
+ | bad.cpp: | ||
+ | 10 | if (a = b) | ||
+ | | ~~^~~ | ||
bad.cpp: | bad.cpp: | ||
- | 10 | if (a == 4) | + | 10 | if (a = b) |
| ^~ | | ^~ | ||
bad.cpp: | bad.cpp: | ||
Line 272: | Line 276: | ||
14 | | 14 | | ||
| ^~~~ | | ^~~~ | ||
- | bad.cpp: | + | bad.cpp: |
- | 8 | | + | 8 | |
| ^ | | ^ | ||
- | bad.cpp:10:5: warning: 'a' is used uninitialized in this function [-Wuninitialized] | + | bad.cpp:10:11: warning: 'b' is used uninitialized in this function [-Wuninitialized] |
- | 10 | if (a == 4) | + | 10 | if (a = b) |
- | | | + | | ~~^~~ |
</ | </ | ||
guides/software/gcc/start.1595169195.txt.gz · Last modified: 2024/07/25 15:01 (external edit)