error not caught at link time: should it be?

N

nzanella

Hello,

I have two .cpp files. The first one contains:

Foo *foo;

and in the second one contains:

Foo foo;

I am using a modified version of gcc
with Makefiles automatically created.
The strange thing is that the tools
go through the link phase without
detecting the error. Isn't it to
be expected that the error be
caught by the linker???

I feel somewhat surprised that
it didn't catch it. I guess
when the linker looks for
external symbols it doesn't
care about matching their
types (eg. pointer versus value).

Thanks!!!

Neil
 
K

Ken Wilson

Hello,

I have two .cpp files. The first one contains:

Foo *foo;

and in the second one contains:

Foo foo;

I am using a modified version of gcc
with Makefiles automatically created.
The strange thing is that the tools
go through the link phase without
detecting the error. Isn't it to
be expected that the error be
caught by the linker???

I feel somewhat surprised that
it didn't catch it. I guess
when the linker looks for
external symbols it doesn't
care about matching their
types (eg. pointer versus value).

Thanks!!!

Neil

I think we need to see more of the actual code. There is the
possibility that you don't get an error because there isn't one as
neither variable resides in the other's scope. You also need to be
aware that C++ will let you 'hide' variables, contrary to behaviour
you would see in a more strictly typed language, i.e. Java, C#, etc.

Ken Wilson
"Coding, coding, over the bounding main()"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top