This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: naive GDB programming style questions


PS: If you encounter a file that has the old ``dud'' struct style indentation then running it (otherwize unchanged) through gdb_indent.sh comes under the ``obvious fix rule''. It lets you get any indentation issues out of the way up before you start making changes.

Andrew


On Mon, 09 Sep 2002 21:45:54 -0400, Andrew Cagney <ac131313@ges.redhat.com> said:


I'll assume that you ment ``p_is_null()''.

Right.


If you've a copy of the ISO C and C++ manuals, have a look at what
they have to say about ``NULL'' pointers.  It's weird.

Really?  Hmm.  I know that NULL doesn't work as well in C++ as it does
in C, so I've gotten used to using 0 there.

Though if you're referring to the fact that NULL's underlying bit
representation might not be 0, I'm not sure that's a big deal here.


Anyway, for GDB, ``p == NULL'' is recommended to make it clear that
the pointer is being tested and not the underlying value.

Okay, then that's what I'll do.


Just use:

struct foo
{
   int mem;
};

which is what is output by gdb_indent.sh and emacs.

Excellent.

David



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]