structure compatibility across translation units 
Author Message
 structure compatibility across translation units

Hi...

This is the interesting program using the rule for structure
compatibility across translation units. (It has no practical value)

/* File: a.c -------------------- */

/* "struct foo" of parameter of "a" is NOT compatible with that of
   x(), but IS compatible with that of b.c */
void f(int a(struct foo { int i; }))
{
 g(a);   /* pass the function pointer to g() in b.c */

Quote:
}

extern int x();   /* non-prototype declaration */

int main(void)
{
 f(x);   /* WELL-DEFINED call to f() */
 reutrn 0;

Quote:
}

/* "struct foo" of x() is NOT compatible with that in f()'s parameter,
   but IS compatible with that of b.c */
int x(struct foo { int i; })
{
 return 0;

Quote:
}

/* File: b.c -------------------- */

struct foo {  int i;  } bar;

void g(int a(struct foo))
{
 a(bar);   /* WELL-DEFINED call */

Quote:
}

Even if both "struct foo" of f() and that of x() ARE compatible with
that of b.c, "struct foo" of f() and that of x() are NOT compatible.

But, At the point that the call to f() occurs in main(), the prototype
declaration of x() is NOT visible (only non-prototype visible), Thus
it's well-defined call to f(), I think.

Is this program strictly conforming?
(If there are any mistakes of interpretation, please point them out)

Thanks...
--



Fri, 18 Jul 2003 13:42:17 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. structure compatibility across translation units

2. struct compatible across translation units

3. extern declaration and definition within the same translation unit

4. meaning of translation unit

5. Filling an empty translation unit

6. translation unit -- what is it?

7. Question about translation units

8. HELP - DCOM across firewall with IP translation

9. Binary data file compatibility across machines

10. Binary data file compatibility across machines

11. lint goofs structure type compatibility

12. how do u group items in a structure across records

 

 
Powered by phpBB® Forum Software