Domain: coding-guidelines.com
Stories and comments across the archive that link to coding-guidelines.com.
Comments · 9
-
Re: Indeed
In C99, the main() function doesn't need any return statement. See 5.1.2.3:
reaching the } that terminates the main function returns a value of 0.
-
Re:For / While in C
That actually breaks the C standard, but I suppose control systems aren't much worried about portability.
The ANSI C standard defines two types of implementations: "hosted" and "freestanding". An embedded system would most likely be considered a freestanding implementation, in which case, the entry point function can be whatever the implementation defines it to be. It might not even be named "main" (but if it is, it could return void if that's what the implementation says). That said, C99 allows main() to return void, even in a hosted implementation: 5.1.2.2.1 gives "some other implementation-defined manner." as one of the options for main's definition. It notes in 5.1.2.2.3 that "If the return type is not compatible with int, the termination status returned to the host environment is unspecified."
-
Re:For / While in C
That actually breaks the C standard, but I suppose control systems aren't much worried about portability.
The ANSI C standard defines two types of implementations: "hosted" and "freestanding". An embedded system would most likely be considered a freestanding implementation, in which case, the entry point function can be whatever the implementation defines it to be. It might not even be named "main" (but if it is, it could return void if that's what the implementation says). That said, C99 allows main() to return void, even in a hosted implementation: 5.1.2.2.1 gives "some other implementation-defined manner." as one of the options for main's definition. It notes in 5.1.2.2.3 that "If the return type is not compatible with int, the termination status returned to the host environment is unspecified."
-
Tracking down the author for fun and profit
Slashdoters now have the authors fingerprints and now some chance of tracking him down. After all developers who write decent quality code are hard to find and HR might offer a finders fee
:-) -
Re:Does it crash less?
You might call that a quality of implementation issue.
:-)That said, my point still stands, and in fact is bolstered: Just because the C standard leaves it undefined doesn't stop compiler writers from giving the situation a useful definition. The resulting language is a superset of C, though, and is thus compiler specific. A program which relies on this variant of C is non-conforming.
I guess the beef here is that "implementation defined" means a program could be conforming but not strictly conforming if it relied on implementation defined behavior, eh?
--Joe -
Measurements I have madeSource code usage measurements contain many surprises (ie, developers don't always write what people think they do). Some statistics I have collected, on a smaller code base, are available here. The source of the tools used to exract much of the data (at least for those tables and figure I produced) is available here (C only at the moment).
Being able to search so much source is also very useful. I was involved in a discussion a while back about the frequency of use of bessel functions in programs (I claimed rare). The handful of uses returned from your database helped back up my argument (dare I say prove it).
Keep up the good work!
-
Thinly Veiled Job Request
Good luck to you too. Youre clearly a knowledgeable and experienced programmer, and being a knowledgeable/experienced programmer means you are probably able to write code that is minimal on bugs, fast, and effective. But what is the purpose of this book? It clearly isnt a commentary; the reference on your homepage to a blog entitled coding guidelines seems more appropriate: the book used the word shall so much when I tried to count the amount Adobe Reader hung for 2 minutes.
Your book is a style guide: a reference of background information and pointers how best to code, and know whats going on. A good C programmer will know this info already (or be on their path there), as the only reason for knowing C today is to interact on a close level with the machine, or to know exactly how things are handled, otherwise theyd be mad not to use a higher level language. A knowledgeable programmer does not need dictating to.
So Im curious, for whom do you intend this book to be most useful for (the book most certainly is useful if someone needed a reference, but given my overriding interpretation of it as a style guide for people who dont need one, it seems to be lost without an audience).
-
Re:Attack the Compiler
-
Re:Attack the Compiler