Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

87%
+12 −0
Q&A What compiler options are recommended for beginners learning C?

When reading questions about C programming from beginners, I very often see them describing peculiar run-time errors and crashes, segmentation faults and similar. They have spent a lot of time chas...

1 answer  ·  posted 3y ago by Lundin‭  ·  edited 3y ago by Lundin‭

#4: Nominated for promotion by user avatar Alexei‭ · 2022-02-13T11:44:18Z (almost 3 years ago)
#3: Post edited by user avatar Lundin‭ · 2021-09-27T08:19:19Z (about 3 years ago)
  • When reading questions about C programming from beginners, I very often see them describing peculiar run-time errors and crashes, segmentation faults and similar. They have spent a lot of time chasing down the bug but failed.
  • Then upon viewing their code, I notice that the code should never have "compiled cleanly" - there were warnings, but the beginner didn't read them. If they had done so, it would have saved them a lot of time.
  • Not reading warnings could in turn be caused by the IDE used hiding away warnings in some hard-to-spot window, or because they picked some "compile & run" option, or simply because they weren't paying attention.
  • Or possibly because they think that warnings mean "here's a little cosmetic issue that you should fix when you have time", and not "here is a severe bug that will likely prevent your program from working as expected" which is closer to the truth most of the time.
  • Unfortunately, a compiler isn't _required_ to give an error upon C language violations. A "diagnostic message" is sufficient, as discussed at [What must a C compiler do when it finds an error?](https://software.codidact.com/posts/277340).
  • **Are there any recommended compiler options beginners should use to avoid accidentally running programs with errors already spotted by the compiler?**
  • Mostly interested in the "gcc-like" mainstream compilers: gcc, clang and icc, which have compatible command-line options.
  • When reading questions about C programming from beginners, I very often see them describing peculiar run-time errors and crashes, segmentation faults and similar. They have spent a lot of time chasing down the bug but failed.
  • Then upon viewing their code, I notice that the code should never have "compiled cleanly" - there were warnings, but the beginner didn't read them. If they had done so, it would have saved them a lot of time.
  • Not reading warnings could in turn be caused by the IDE used, which is hiding away warnings in some hard-to-spot window, or because they picked some "compile & run" option, or simply because they weren't paying attention.
  • Or possibly because they think that warnings mean "here's a little cosmetic issue that you should fix when you have time", and not "here is a severe bug that will likely prevent your program from working as expected" which is closer to the truth most of the time.
  • Unfortunately, a compiler isn't _required_ to give an error upon C language violations. A "diagnostic message" is sufficient, as discussed at [What must a C compiler do when it finds an error?](https://software.codidact.com/posts/277340)
  • **Are there any recommended compiler options beginners should use to avoid accidentally running programs with errors already spotted by the compiler?**
  • Mostly interested in the "gcc-like" mainstream compilers: gcc, clang and icc, which have compatible command-line options.
#2: Post edited by user avatar Lundin‭ · 2021-07-06T08:42:05Z (over 3 years ago)
  • When reading questions about C programming from beginners, I very often see them describing peculiar run-time errors and crashes, segmentation faults and similar. They have spent a lot of time chasing down the bug but failed.
  • Then upon viewing their code, I notice that the code should never have "compiled cleanly" - there were warnings, but the beginner didn't read them.
  • Not reading warnings could in turn be caused by the IDE used hiding away warnings in some hard-to-spot window, or because they picked some "compile & run" option, or simply because they weren't paying attention.
  • Or possibly because they think that warnings mean "here's a little cosmetic issue that you should fix when you have time", and not "here is a severe bug that will likely prevent your program from working as expected" which is closer to the truth most of the time.
  • Unfortunately, a compiler isn't _required_ to give an error upon C language violations. A "diagnostic message" is sufficient, as discussed at [What must a C compiler do when it finds an error?](https://software.codidact.com/posts/277340).
  • **Are there any recommended compiler options beginners should use to avoid accidentally running programs with errors already spotted by the compiler?**
  • Mostly interested in the "gcc-like" mainstream compilers: gcc, clang and icc, which have compatible command-line options.
  • When reading questions about C programming from beginners, I very often see them describing peculiar run-time errors and crashes, segmentation faults and similar. They have spent a lot of time chasing down the bug but failed.
  • Then upon viewing their code, I notice that the code should never have "compiled cleanly" - there were warnings, but the beginner didn't read them. If they had done so, it would have saved them a lot of time.
  • Not reading warnings could in turn be caused by the IDE used hiding away warnings in some hard-to-spot window, or because they picked some "compile & run" option, or simply because they weren't paying attention.
  • Or possibly because they think that warnings mean "here's a little cosmetic issue that you should fix when you have time", and not "here is a severe bug that will likely prevent your program from working as expected" which is closer to the truth most of the time.
  • Unfortunately, a compiler isn't _required_ to give an error upon C language violations. A "diagnostic message" is sufficient, as discussed at [What must a C compiler do when it finds an error?](https://software.codidact.com/posts/277340).
  • **Are there any recommended compiler options beginners should use to avoid accidentally running programs with errors already spotted by the compiler?**
  • Mostly interested in the "gcc-like" mainstream compilers: gcc, clang and icc, which have compatible command-line options.
#1: Initial revision by user avatar Lundin‭ · 2021-07-06T08:15:56Z (over 3 years ago)
What compiler options are recommended for beginners learning C?
When reading questions about C programming from beginners, I very often see them describing peculiar run-time errors and crashes, segmentation faults and similar. They have spent a lot of time chasing down the bug but failed.

Then upon viewing their code, I notice that the code should never have "compiled cleanly" - there were warnings, but the beginner didn't read them. 

Not reading warnings could in turn be caused by the IDE used hiding away warnings in some hard-to-spot window, or because they picked some "compile & run" option, or simply because they weren't paying attention.

Or possibly because they think that warnings mean "here's a little cosmetic issue that you should fix when you have time", and not "here is a severe bug that will likely prevent your program from working as expected" which is closer to the truth most of the time.

Unfortunately, a compiler isn't _required_ to give an error upon C language violations. A "diagnostic message" is sufficient, as discussed at [What must a C compiler do when it finds an error?](https://software.codidact.com/posts/277340).

**Are there any recommended compiler options beginners should use to avoid accidentally running programs with errors already spotted by the compiler?**

Mostly interested in the "gcc-like" mainstream compilers: gcc, clang and icc, which have compatible command-line options.