This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc4.1.0: error: object missing in reference to
- From: John Love-Jensen <eljay at adobe dot com>
- To: Perry Smith <pedz at easesoftware dot com>
- Cc: Fabian Cenedese <Cenedese at indel dot ch>, MSX to GCC <gcc-help at gcc dot gnu dot org>
- Date: Tue, 05 Dec 2006 14:10:16 -0600
- Subject: 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