Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VC++ 2010 - best way to do this !

17 views
Skip to first unread message

jism...@gmail.com

unread,
Jan 28, 2013, 3:37:35 PM1/28/13
to

Hello guys,

please help me with following problem.

I have a.c which includes a.h
i have b.c which includes b.h
i have b.h which includes c.h (c.lib included)

a.c uses some functions which are defined in c.lib.
so i included b.h in a.h therby including c lib functions.

but iam writing something like hardware abstraction layer.
I dont want a.c access c.lib functions directly.
One way is to include c.h in b.c instead of b.h

What would be the standard pro way to do this.

Please help me. (using visual studio 2010 express on windows 7)

thanks,
jis
Show trimmed content

David Webber

unread,
Jan 30, 2013, 8:37:59 AM1/30/13
to
>===
====<

Why does b.h need to include c.h ?

b.c can include both b.h and c.h

I can see that one reason for the problem might be if some functions defined
in b.h have as arguments structures (let me call one 'struct XYZ') which are
defined in c.h. The standard way to handle this in C++ (I'm rusty on
what's allowed in C) is to make sure the b.h function arguments are
references or pointers to the structures, and then provide forward
definitions at the start of b.h like

struct XYZ;

so that it knows that XYZ is a structure name, and that the implementation
in b.c will get the details from another header (in this case c.h). Then
b.h does not need to include c.h

Dave

-- David Webber
Mozart Music Software
http://www.mozart.co.uk/

0 new messages