how to avoid using another header file inside a header file?

From: Newsgroup - Ann (news_ann_at_yahoo.com)
Date: 11/02/03


Date: Sat, 1 Nov 2003 23:18:45 -0500

I have a library function like GetOptions( ..., struct net_arch_t netArch,
...) and put the declaration into a regular header file like getopt.h. But
this function declaration also needs the declaration of struct net_arch_t
which is located in another header file, e.g., nn.h. I saw somewhere that it
should be avoided to include another header file inside one header file. So
I am trying to use some other methods.

One option is for each source file that needs the GetOption function,
include both the getopt.h and nn.h and place nn.h ahead of the getopt.h. But
isn't it awkard? Is there any better way to do it? It happens some often to
me. Thanks.

Ann



Relevant Pages

  • Re: Newbie question
    ... >>> What I've done is declare a struct in a header file, ... >> Declaring structs, typedefs, function prototypes etc yes, defining ... >the header file and not again referenced in the code. ... >the header file in each code file is a duplicate declaration, ...
    (comp.lang.c)
  • Re: Error C2259 while building application on 64-bit
    ... build to the header file you use in the 64-bit build. ... 'HRESULT IPersistFolder::Initialize': is ... declaration of 'IShellFolder::ParseDisplayName' ... while compiling class template member function 'HRESULT ...
    (microsoft.public.vc.mfc)
  • Re: Rob Pikes simple Include rule
    ... UINT8 Public_Function ... and I want to make it public, I put it into a header file ... Now, since it uses the UINT8 and UINT16 in the declaration, ... C++ Faq: http://www.parashift.com/c++-faq-lite C Faq: http://www.eskimo.com/~scs/c-faq/top.html alt.comp.lang.learn.c-c++ faq: ...
    (comp.lang.c)
  • Re: External structs - newbie question
    ... The header file for csd.c contains the typedef for a ... There is only one struct in use ... Declaring it in a header file is the right way to go. ... If you put the keyword extern before the declaration, it will not be a problem declaring it twice. ...
    (comp.lang.c)
  • Re: Register my own messages
    ... include the header file except in the modules that actually use it. ... I defined int CODERSOURCEMSG in a header file appart. ... the declaration merely declares its type and name so that it can be used. ... extern const int UWM_MYMSG; ...
    (microsoft.public.vc.mfc)