Re: Same-name typedefS in separate translation units
- From: David Thompson <dave.thompson2@xxxxxxxxxxx>
- Date: Fri, 13 Feb 2009 23:59:28 -0600 (CST)
On Mon, 2 Feb 2009 23:44:24 -0600 (CST), Andrew Talbot
<t7dy4p902@xxxxxxxxxxxxxx> wrote:
I have two files with different struct types that have the same name as each<snip>
other, and both are wrapped in typedefS with identical names as follows
(simplified).
file1.c:
typedef struct s S;
struct s { char *pc; int n; };
....
file2.c:
typedef struct s S;
struct s { char *pc; long n; };
I believe that the struct declarations do not inherently conflict in thisThe 'incomplete' (here, just forward) type doesn't matter. ALL type
case (see http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1226.pdf), so if
the variable "st", in file2.c, were instead declared as having type
struct s *, it would use the local version of "s". But the question is do
the typedefS conflict and spoil this defined behavior, or does their
apparent "incomplete type" nature prevent that?
declarations are local to a translation unit at most, so this is fine
for compilation. Objects/variables and functions declared with
external linkage do have 'global'=program scope, but formally linkage
is not the same thing as declaration, and types have no linkage.
Although the standard intentionally doesn't talk about implementation,
this actually reflects the important implementation difference between
compiler symbols and linker symbols, which are related but decidedly
not the same thing.
However, if you want to (be able to) debug the resulting program with
a symbolic (i.e. half-decent) debugger, which is outside the scope of
the C standard, THAT may very well have problems with this.
--
comp.lang.c.moderated - moderation address: clcm@xxxxxxxxxxxx -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
.
- Prev by Date: Re: Same-name typedefS in separate translation units
- Next by Date: Re: Variable Scope ?
- Previous by thread: Re: Same-name typedefS in separate translation units
- Next by thread: Re: gui
- Index(es):
Relevant Pages
|