This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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: gcc4.1.0: error: object missing in reference to


Hi Perry,

> struct foo
> {
>      typedef char buf_type[1024];
> 
>      buf_type buf;
> };

Yep, that also will work.

What's the optimal approach for Fabian depends on the problem at hand.

My tendency is to use a const, where the const would be implemented in terms
of the sizeof the buf in the context of a null pointer:

const size_t kBufSize = sizeof(((foo*)NULL)->buf);

Or, alternatively (when an option), go the other direction:

const size_t kBufSize = BUFFER_SIZE - HEADER_SIZE;
struct foo
{
  char buf[kBufSize];
};

If a private: scoping is thrown into the mix, then that changes the game
plan.  Hopefully in such a scenario all access is internal to the class
(nicely encapsulated), so the code that needs to sniff these things has
visible access to them.

Sincerely,
--Eljay


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