public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc4.1.0: error: object missing in reference to
@ 2006-12-05  9:52 Fabian Cenedese
  2006-12-05 13:19 ` John Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Fabian Cenedese @ 2006-12-05  9:52 UTC (permalink / raw)
  To: gcc-help

Hi

I have a problem I don't know how to solve:

struct SINOSEventLogBuffer
{
...(snip)...
	uint8 m_cData[LOGGER_BUF_SIZE-LOGGER_HEADER_SIZE];
...(snip)...
};

m_uMaxEntrySize = sizeof(SINOSEventLogBuffer::m_cData);

And that gives me:

CINOSEventLogger.h:322: error: object missing in reference to 'SINOSEventLogBuffer::m_cData'
CINOSEventLogger.cpp:180: error: from this location

I tried to find the solution on the internet but I couldn't find much about it.

1. Is this really an error? Seems quite correct to me.
2. Is this a bug in gcc? Possibly already solved in 4.1.1 or later?

Thanks

bye   Fabi


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: gcc4.1.0: error: object missing in reference to
  2006-12-05  9:52 gcc4.1.0: error: object missing in reference to Fabian Cenedese
@ 2006-12-05 13:19 ` John Love-Jensen
  2006-12-05 13:40   ` Fabian Cenedese
  0 siblings, 1 reply; 9+ messages in thread
From: John Love-Jensen @ 2006-12-05 13:19 UTC (permalink / raw)
  To: Fabian Cenedese, MSX to GCC

Hi Fabian,

Is m_cData a static member?

If not, then I don't think you can do a sizeof(SINOSEventLogBuffer::m_cData)
on that.

Try this instead:

m_uMaxEntrySize = sizeof(((SINOSEventLogBuffer*)NULL)->m_cData);

Or use this:

m_uMaxEntrySize = LOGGER_BUF_SIZE-LOGGER_HEADER_SIZE;

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: gcc4.1.0: error: object missing in reference to
  2006-12-05 13:19 ` John Love-Jensen
@ 2006-12-05 13:40   ` Fabian Cenedese
  2006-12-05 13:57     ` John Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Fabian Cenedese @ 2006-12-05 13:40 UTC (permalink / raw)
  To: gcc-help

At 07:19 05.12.2006 -0600, you wrote:
>Hi Fabian,
>
>Is m_cData a static member?

No, normal struct member.

>If not, then I don't think you can do a sizeof(SINOSEventLogBuffer::m_cData)
>on that.

Why is that a problem? I can do sizeof(SINOSEventLogBuffer) without
a problem, why not a member as well? Older gcc's didn't have a problem
with that. I know, newer gcc's have much stricter checking.

Even if this is considered not good programming style, why is it so serious
to be an error and not just a warning?

>Try this instead:
>
>m_uMaxEntrySize = sizeof(((SINOSEventLogBuffer*)NULL)->m_cData);

Yes, that works, thanks a lot.

bye  Fabi


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: gcc4.1.0: error: object missing in reference to
  2006-12-05 13:40   ` Fabian Cenedese
@ 2006-12-05 13:57     ` John Love-Jensen
  2006-12-05 15:30       ` Fabian Cenedese
  0 siblings, 1 reply; 9+ messages in thread
From: John Love-Jensen @ 2006-12-05 13:57 UTC (permalink / raw)
  To: Fabian Cenedese, MSX to GCC

Hi Fabian,

>Even if this is considered not good programming style, why is it so serious to
be an error and not just a warning?

Because it isn't C++.

If you want a language that is nearly-C++-but-not-C++ ... well, you are free
to create your own language.  (Which is nearly verbatim what Bjarne
Stroustrup told me when I presented him my list of "improvements" to C++
back in the early 90's.)

For a language that is nearly-C++-but-not-C++ that addresses a lot of what I
consider shortcomings in C++, I'm pretty much smitten with D Programming
Language (http://www.digitalmars.com/d/index.html).

Several co-workers of mine are strong advocates of the benefits of
tried-and-true Ada over C++ (http://www.adahome.com/).

For rising popularity, it is hard to argue against the success of Java
(http://java.sun.com/) especially in conjunction with the fantastic Eclipse
IDE (http://www.eclipse.org/), which also addresses what some would consider
shortcomings in C++ and enabling technology for software engineering.

Sincerely,
--Eljay

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: gcc4.1.0: error: object missing in reference to
  2006-12-05 13:57     ` John Love-Jensen
@ 2006-12-05 15:30       ` Fabian Cenedese
  2006-12-05 15:52         ` John Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Fabian Cenedese @ 2006-12-05 15:30 UTC (permalink / raw)
  To: gcc-help

At 07:57 05.12.2006 -0600, John Love-Jensen wrote:
>Hi Fabian,
>
>>Even if this is considered not good programming style, why is it so serious to
>be an error and not just a warning?
>
>Because it isn't C++.

Well, I didn't know that. I thought it may be "not that good" but still valid.
But we'll stay with C++ :) Do you know a link where this is explained?
There are many C++ references out there, but I can't find this case.

Thanks

bye  Fabi


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: gcc4.1.0: error: object missing in reference to
  2006-12-05 15:30       ` Fabian Cenedese
@ 2006-12-05 15:52         ` John Love-Jensen
  2006-12-05 16:27           ` Perry Smith
  0 siblings, 1 reply; 9+ messages in thread
From: John Love-Jensen @ 2006-12-05 15:52 UTC (permalink / raw)
  To: Fabian Cenedese, MSX to GCC

Hi Fabian,

> Well, I didn't know that. I thought it may be "not that good" but still valid.
> But we'll stay with C++ :) Do you know a link where this is explained?
> There are many C++ references out there, but I can't find this case.

I don't have a link, but I can cite the standard which states what is
acceptable for the sizeof operator:
ISO 14882 section 5.3.3

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: gcc4.1.0: error: object missing in reference to
  2006-12-05 15:52         ` John Love-Jensen
@ 2006-12-05 16:27           ` Perry Smith
  2006-12-05 16:44             ` Fabian Cenedese
  2006-12-05 20:10             ` John Love-Jensen
  0 siblings, 2 replies; 9+ messages in thread
From: Perry Smith @ 2006-12-05 16:27 UTC (permalink / raw)
  To: John Love-Jensen; +Cc: Fabian Cenedese, MSX to GCC

On Dec 5, 2006, at 9:52 AM, John Love-Jensen wrote:

> Hi Fabian,
>
>> Well, I didn't know that. I thought it may be "not that good" but  
>> still valid.
>> But we'll stay with C++ :) Do you know a link where this is  
>> explained?
>> There are many C++ references out there, but I can't find this case.
>
> I don't have a link, but I can cite the standard which states what is
> acceptable for the sizeof operator:
> ISO 14882 section 5.3.3

I see... So I could do this:

#include <iostream>
using namespace std;

struct foo
{
     typedef char buf_type[1024];

     buf_type buf;
};

int main()
{
     cout << sizeof(foo::buf_type) << endl;
}

Perry Smith ( pedz@easesoftware.com )
Ease Software, Inc. ( http://www.easesoftware.com )

Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: gcc4.1.0: error: object missing in reference to
  2006-12-05 16:27           ` Perry Smith
@ 2006-12-05 16:44             ` Fabian Cenedese
  2006-12-05 20:10             ` John Love-Jensen
  1 sibling, 0 replies; 9+ messages in thread
From: Fabian Cenedese @ 2006-12-05 16:44 UTC (permalink / raw)
  To: MSX to GCC


>>I don't have a link, but I can cite the standard which states what is
>>acceptable for the sizeof operator:
>>ISO 14882 section 5.3.3
>
>I see... So I could do this:
>
>struct foo
>{
>    typedef char buf_type[1024];
>   buf_type buf;
>};
>
>int main()
>{
>    cout << sizeof(foo::buf_type) << endl;
>}

That may be usefull as well. Thanks.

bye  Fabi


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: gcc4.1.0: error: object missing in reference to
  2006-12-05 16:27           ` Perry Smith
  2006-12-05 16:44             ` Fabian Cenedese
@ 2006-12-05 20:10             ` John Love-Jensen
  1 sibling, 0 replies; 9+ messages in thread
From: John Love-Jensen @ 2006-12-05 20:10 UTC (permalink / raw)
  To: Perry Smith; +Cc: Fabian Cenedese, MSX to GCC

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-12-05 20:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-05  9:52 gcc4.1.0: error: object missing in reference to Fabian Cenedese
2006-12-05 13:19 ` John Love-Jensen
2006-12-05 13:40   ` Fabian Cenedese
2006-12-05 13:57     ` John Love-Jensen
2006-12-05 15:30       ` Fabian Cenedese
2006-12-05 15:52         ` John Love-Jensen
2006-12-05 16:27           ` Perry Smith
2006-12-05 16:44             ` Fabian Cenedese
2006-12-05 20:10             ` John Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).