[ILUG] Re: programming question

From: John P . Looney (valen at domain tuatha.org)
Date: Fri 17 Sep 1999 - 09:31:08 IST


On Fri, Sep 17, 1999 at 08:28:54AM +0100, Vincent Cunniffe mentioned:
> I want to compile a single executable from two separate source files, both
> of which need access to the data definitions, such as structures.
>
> I can 'extern' the actual data definitions themselves, but the structs refuse
> to be 'extern'ed, and the compiles fail on duplicate definitions.
>
> Solution :
>
> typedef?

header1:

typedef struct mystruct_ {
    stuff...
    more stuff...
} mystruct;

file1:

#include "header1"
 mystruct instance;
 mystruct instance2;

stuff that uses instances...

file2:

#include "header1"
 extern mystruct instance;

 stuff that uses instance....

 OK ?

Kate

-- 
Microsoft. The best reason in the world to drink beer.


This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:34 GMT