 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
nzanella@cs.mun.ca Guest
|
Posted: Wed Jul 27, 2005 6:35 pm Post subject: error not caught at link time: should it be? |
|
|
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
|
|
| Back to top |
|
 |
Ken Wilson Guest
|
Posted: Wed Jul 27, 2005 7:03 pm Post subject: Re: error not caught at link time: should it be? |
|
|
On 27 Jul 2005 11:35:48 -0700, [email]nzanella (AT) cs (DOT) mun.ca[/email] did courageously
avow:
| Quote: | 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()"
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|