Article View: comp.std.c++
Article #3430Type conflicts
From: Erik Oestlyngen
Date: Fri, 23 Feb 1996 19:45
Date: Fri, 23 Feb 1996 19:45
64 lines
1899 bytes
1899 bytes
Hi.
I'm doing working with a project trying to make a model for namespace
structure of C++ programs, and make a visualization of it. (by the
way, does anyone know of any interesting stuff on the net in this
context ?)
Anyhow, i've got this little problem:
When i define two different structs with the same name in two
different files, my compiler don't complain. I can then use the struct
as input parameter for a function in one file, and from the other send
the different struct into the function. The function will then get
an other input type than it expects.
What does the ansi-C++ standard say about this?
Example:
========
File1:
struct a {
int x;
};
extern void f(struct a);
void main(void)
{
struct a str;
str.x=1;
f(str);
}
---------------------
File2:
struct a {
long x;
};
void f(struct a astr)
{
astr.x+=2; // crash, bang, crunch
}
--
--Erik Oestlyngen
---------------------------------------------------------------
erikoest@idt.unit.no URL http://www.idt.unit.no/~erikoest/
[ To submit articles: Try just posting with your newsreader.
If that fails, use mailto:std-c++@ncar.ucar.edu
FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID:
<ye7bumpal7p.fsf@pil.idt.unit.no>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: erikoest@idt.unit.no (Erik Oestlyngen) Newsgroups: comp.std.c++ Subject: Type conflicts Date: 23 Feb 1996 19:45:00 GMT Organization: Norwegian University of Science and Technology Sender: erikoest@pil.idt.unit.no Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <ye7bumpal7p.fsf@pil.idt.unit.no> NNTP-Posting-Host: taumet.eng.sun.com X-Nntp-Posting-Host: pil.idt.unit.no X-Newsreader: Gnus v5.0.4 Originator: clamage@taumet