Re: C coding style
Posted: Wed Jun 29, 2011 7:13 am
Oops, I missed all the discussion that's been going on since I last posted. It seems Solar had already covered the problem with using hard tabs.
Write the code in a text editor, compile test it, and then paste it. Surely nobody sane writes code directly on the Wiki.berkus wrote:Please, how will you enter them into the wiki? I'm interested.Brynet-Inc wrote:Tabs > Spaces.
There, fixed that for you.NickJohnson wrote:I think the whole tabs/spaces thing is largely irrelevant, as long as tabs are not used for anything.
As far as tabs and spaces go, this makes the most sense to me.NickJohnson wrote:I think the whole tabs/spaces thing is largely irrelevant, as long as tabs are not used for anything other than indentation...
+1.Brynet-Inc wrote:Write the code in a text editor, compile test it, and then paste it. Surely nobody sane writes code directly on the Wiki.berkus wrote:Please, how will you enter them into the wiki? I'm interested.Brynet-Inc wrote:Tabs > Spaces.
Sadly enough, not really.Darwin wrote:As far as tabs and spaces go, this makes the most sense to me.NickJohnson wrote:I think the whole tabs/spaces thing is largely irrelevant, as long as tabs are not used for anything other than indentation...
Code: Select all
// Assuming a TAB display width of 4
int main( int argc, char * argv[] )
{
>---// somewhat constructed, but you know what I mean
>---for ( int i = 0;
>--- i < n; // #1
>--- ++i ) // #2
>---{
>--->---// BODY
No we don't. Discussions of personal preference have already been excluded from changing the proposed style guide.Do we really need to have a vote on this?
Except the style guide is more or less the preferences Solar and you had, just that no one really cared to impose their own.Combuster wrote:No we don't. Discussions of personal preference have already been excluded from changing the proposed style guide.Do we really need to have a vote on this?
Ahem, I gave my preferences.They just happened to be aligned with what Solar and Combuster were saying.Love4Boobies wrote:Except the style guide is more or less the preferences Solar and you had, just that no one really cared to impose their own.Combuster wrote:No we don't. Discussions of personal preference have already been excluded from changing the proposed style guide.Do we really need to have a vote on this?
As much as I would have loved that argument to be true , it isn't. (Yes, I immediately whipped up my copy of the C99 standard.)Love4Boobies wrote:Misalignment is not the only problem with tabs. Using them results in undefined behavior according to the C standard, as they are not guaranteed to be part of the source character set (unlike for the execution character set). There, your code is not only aesthetically volatile, but also invalid.
Guilty as charged.Combuster wrote:Except the style guide is more or less the preferences Solar and you had, just that no one really cared to impose their own.
Oops, I got excited for nothing That sentence starts with "Both the basic source and basic execution character sets"Solar wrote:As much as I would have loved that argument to be true , it isn't. (Yes, I immediately whipped up my copy of the C99 standard.)Love4Boobies wrote:Misalignment is not the only problem with tabs. Using them results in undefined behavior according to the C standard, as they are not guaranteed to be part of the source character set (unlike for the execution character set). There, your code is not only aesthetically volatile, but also invalid.
According to chapter 5.2.2 of the standard, the source character set includes "control characters representing horizontal tab, vertical tab, and form feed" (whatever good that would do).