Re: C/C++ lua_stackdump lib - feedback welcome
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: C/C++ lua_stackdump lib - feedback welcome
- From: Philipp Janda <siffiejoe@...>
- Date: 2016年10月11日 08:09:39 +0200
Am 10.10.2016 um 16:58 schröbte M. Gerhardy:
Hi.
Hi!
I was looking for a way to do stackdumps from within C/C++ - I couldn't
find anything that also prints tables.
That's why I did this small helper header file:
https://github.com/mgerhardy/lua_stackdump
Feedback is more than welcome.
I found that using stack dumps unconditionally can get very confusing --
especially if there is a lot of output and if you use it in multiple
places at the same time or in loops. So I've switch to some form of
stack assertion where I specify what I think the top-most elements of
the stack should look like, and the stack contents only get dumped when
the actual stack contents are different.
What also helps is the source file name, line number, and function name
where the stack dump is from (`__FILE__`, `__LINE__`, and `__func__` (or
`__FUNCTION__` for MSVC)).
Kind regards
Martin
Philipp
p.s.: About the braces thing: I prefer one-statement control structures
without the braces because of vertical space. I use a lot of split
windows and vim buffers, and
if( something )
{
do_something();
}
is twice as long as the alternative.