Another thread was about this, I was just wondering: how do you indent your source code?
I prefer indenting with two spaces.
Tabs
1 space per level
2 or 3 spaces per level
4 through 6 spaces per level
7+ spaces per level
Another thread was about this, I was just wondering: how do you indent your source code?
I prefer indenting with two spaces.
4 spaces. I used to use tabs until I realized it made the source code look different depending on what application was viewing it.
bit∙hub [bit-huhb] n. A source and destination for information.
@Echo bithub
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
I bet a bunch of newbies are going to read this thread and be like "huh? wuzzat???".
Anyway, one tab or 6 spaces.
So, we need to periodically hold this poll so as to determine some trend?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Well, there seems to be several threads about indent style, but the one that most closely matches this poll is... How far do you indent?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I use tabs (set to the width of 4 spaces) because we use Visual C++ exclusively for our coding and tabs are easiest to work with.
On personal projects I often set my editor to convert tabs to spaces (still at 4 spaces per tab). For code I post on forums I have a macro that converts all tabs to 4 spaces that I run before posting since tabs don't look so good on these forums.
I'd like to add that one space just isn't sufficient. On a side note, I wonder if anyone indents using only semicolens?
I follow Linus's lead:Originally Posted by Linus Torvalds
Is the fact that you can no longer see straight supposed to be some sort of justification here? I mean I sometimes like marathon sessions but I would not use them as an excuse ("after 5 hits of acid and a case of beer, you'll find it a lot easier to see how the indentation works if you have large indentations"). If you are becoming confused by 4 char tabs, please call it a night.
I use tabs set to 4 characters but I don't care much, 2, 4, or 8 is fine. I switched from 8 to 4 because a block nested 6 or 7 levels deep is so far inset that you must start scrolling horizontally for long lines. I didn't vote because the poll seems flawed to me, insofar as it contrasts "a tab" with any number of spaces.
I'll draw the line at one, tho. 1 character is not indentation.
Last edited by MK27; 09-22-2009 at 03:09 PM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
Yes. I wasn't criticizing Kennedy, I was criticizing Mr. Torvalds. However, the part of the kernel source that I have looked at does seem to be mostly short functions and the nesting never gets past 3 or 4 levels, so maybe he is trying light the way down a certain path, I dunno.
Last edited by MK27; 09-22-2009 at 07:12 PM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge