questions about include

Started by
2 comments, last by violentrevolution 11 years, 3 months ago
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?
Advertisement

[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.

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?
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.

This topic is closed to new replies.

Advertisement