Thanks Aaron,

We will try your method, and we'll keep you updated on our results.

thanks for your help

alex

----- Original Message -----
From: "Aaron Ardiri" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, October 24, 1999 1:38 PM
Subject: Re: Passing structures to new functions


hi!

> Thanks for responses, but I think I need to make our problem a little
> clearer. I am using several .cpp files in my project. I would like to have
> one header file that contains all my function prototypes. This has been
> working great until I tried to prototype a function that has a structure
> data type as one of its parameters. I tried what Ralph suggested and it
> works just fine but that is not what I am trying to do. What I have done
to
> get around this is to prototype the function in the files that will use
the
> function. This seems to work. But again its not the way I would like to do
> it.

  this is how i do it:

--
myHeader.h

#ifndef _myHeader
#define _myHeader

typedef struct
{
  int a;
} MyStruct, *MyStructPtr;

extern void myFunction(MyStruct);

#endif // myHeader
--

  *every* file includes this file - and the function is being
  declared external, so it is up to the linked to sort that out,
  not the compiler.

  the reason for putting the "#ifndef" in there is to prevent
  the compiler redefining the structure again (it is ok to define
  the prototypes again).

  if this is what you are after.. it works for me. of course my
  situation differs as i have a large number of sub files
  (components in my system) - that have their own header files.
  in that case the main header file is generated by using a load
  of #include's - which does the same thing.

  hope this helps.

az.
--
Aaron Ardiri
Lecturer                       http://www.hig.se/~ardiri/
University-College i G�vle     mailto:[EMAIL PROTECTED]
SE 801 76 G�vle SWEDEN
Tel: +46 26 64 87 38           Fax: +46 26 64 87 88
Mob: +46 70 656 1143           A/H: +46 26 10 16 11




Reply via email to