From: Philip B. <ph...@bo...> - 2003-04-29 23:52:32
|
On Tue, Apr 29, 2003 at 04:28:03PM -0700, Ian Romanick wrote: > Philip Brown wrote: > > Why? Casts are an integral part of the language. > > There are "clean" ways to handle casts. > > Examples in the current Mesa code base: > > Because if you do foo( (base_type *) x ) and x is not a derived type, > the compiler can't help you. If you do foo( & x->base ) and x is not a > derived type, the compiler will generate a warning. The casting should only be happening under controlled, rare circumstances, where screwing up the object type isnt really an issue. Hypothetical examples: inline GLXfbuf* getGLXdrawbuffer(GLcontext *ctx){ return (GLXfbuf*) ctx->DrawBuffer; } inline void setGLXdrawbuffer(GLcontext *ctx,GLXfbuf*fbuf){ ctx->DrawBuffer = (GLframebuffer*)fbuf; } Oooo... feels kinda like C++ member functions, how about that... :-) |