Sign in to follow this  
noatom

questions about include

Recommended Posts

noatom    927
Everyone knows that using include on a file makes the compiler treat that file as it was part of our code.

But what happens when we use include <windows.h> ? This is where i'm a little foggy,suppose we make an exe that uses some code from windows.h,will the code needed be nested inside that little exe?

And here is the question that got me in fog: What happens when we use include in a dll?
Suppose that i make a dll that uses code from the directx headers.Will it nest the required code inside the dll?

I'm asking because in a book,the author says something like this:
if you create the direct3d device in a dll,you don't need to include the directx headers in a project that uses that dll,you can just call functions inside the dll that will use the device(that is in the dll ofcourse) to do stuff.

So how does including in a dll work?

Share this post


Link to post
Share on other sites

[quote name='noatom' timestamp='1357230915' post='5017175']
if you create the direct3d device in a dll,you don't need to include the directx headers in a project that uses that dll,you can just call functions inside the dll that will use the device(that is in the dll ofcourse) to do stuff
[/quote]

I see that you have answered the query yourself. The reason why you won't need to include same headers into the project, that's using the dll which provides the functions needed, is because that header and related info is already included in the dll.

This is sort of a rule and doesn't change for any .h, .pch. cpp, .cc, .etc. leave alone windows headers.

Share this post


Link to post
Share on other sites
noatom    927
but wait...does that mean that for exemple if I include a directx sdk header in a dll,that header will just get in the dll file? So if I move the dll to another PC,it won't need the directx sdk,because the header file is already in the dll itself?

Share this post


Link to post
Share on other sites
but wait...does that mean that for exemple if I include a directx sdk header in a dll,that header will just get in the dll file? So if I move the dll to another PC,it won't need the directx sdk,because the header file is already in the dll itself?

Unless you're trying to use the same functions from the sdk, which also have been included in the dll, you won't need the header.

Lets consider an example :

 

A project called MyGraphicsImpl is created, that provides the direct3d implementation as part of their MGI.dll. Now you want to use this project and do some of your own things.

They have a method called CustomCreateDevice, which basically does a Direct3D CreateDevice internally. Ofcourse, to use CustomCreateDevice you need to include their header called CustomCreateDevice.h in your code. But there is no need to use anything from DirectX SDK anymore.

This is the underlying concept of quite a few third party source code that is developed and used across the fraternity.

I hope this explains the idea.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this