[mythtv] C++ style
Daniel Thor Kristjansson
danielk at cat.nyu.edu
Wed Feb 11 15:03:45 EST 2004
Classes are the real reason to prefer pre-increment over post-increment,
with integers the compiler will figure it out. There is also a backward
compatibility reason for it. In old school C ++i is defined as a
pre-increment and i++ is defined as "whatever is fastest" so there is
no actual post-increment in C. Many compilers including gcc support it
as a post-increment because that's less surprising, but you might not
want to depend on that.
As for indentation, I've just written this bit of emacs lisp...
(defconst myth-c-style
'((c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((substatement-open before after)))
(c-offsets-alist . ((topmost-intro . 0)
(substatement . +)
(substatement-open . 0)
(case-label . +)
(access-label . -)
(inclass . ++)
(inline-open . 0)
))
)
)
(c-add-style "myth" myth-c-style t)
You can put it in your .emacs and then load it with
M-x set-c-style <CR> myth <CR>
OR, add this to your .emacs to make it the default
(add-hook 'c-mode-common-hook
(function
(lambda ()
(c-set-style "myth")
)
)
-- Daniel
<< When truth is outlawed; only outlaws will tell the truth. >> - RLiegh
On Wed, 11 Feb 2004, Jens Lohmann-Hansen wrote:
]On Wednesday 11 February 2004 20:02, Paul Woodward wrote:
]> > On Wednesday 11 February 2004 13:25, steve at nexusuk.org wrote:
][...]
]> > if (somevar == ++i)
]> > is definitely different than
]> > if (somevar == i++)
]>
]> I don't think even Microsoft could come up with up with a compiler that
]> generates such poor code that it takes a significant time to INC a register
]> on an nGhz chip!
]
]I'm sure others will point this out - but you can overload operators in C++;
]so the "INC a register" seems a bit narrowminded to me.
]
]/Jens
]_______________________________________________
]mythtv-dev mailing list
]mythtv-dev at mythtv.org
]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
]
More information about the mythtv-dev
mailing list