Re: Accessing members of a struct
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Tue, 11 Apr 2006 14:51:42 -0400
joseph.paterson@xxxxxxxxx wrote:
I'm having some trouble with accessing members of a structure i've
defined...
I've got something like this:
#define bool short int
#define TRUE 1
#define FALSE 0
#define SMOOTH_FACTOR (3.0 / 4.0)
typedef struct {
float x, y, z;
int r, g, b;
bool isDefined;
} Vertex;
followed by:
Several suggestions. First, make it easy for someone to extract
and compile your code. That means limiting line length to about 65
or so, not using // comments, and ensuring that the code is
suitably indented and consistently formatted.
Second, the very presence of "#define TRUE 1" is a red flag. In C,
an expression is true if it is non-zero. Thus "#define FALSE 0" is
unlikely to induce errors, but the TRUE value is highly error
prone. I also don't like the definition of bool, but that is more
my taste than error probabilities.
Third, your code should be complete, so it only needs to be copied
and compiled. Then you can state clearly the input, the
expectations, and the failures.
Since you are posting from that broken usenet interface at google,
read my sig. below and the referenced URLs therein before posting
again or replying.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
.
- References:
- Accessing members of a struct
- From: joseph . paterson
- Accessing members of a struct
- Prev by Date: Re: Some Questions
- Next by Date: Re: C header files--Urgent
- Previous by thread: Re: Accessing members of a struct
- Next by thread: Re: Accessing members of a struct
- Index(es):
Relevant Pages
|