thanks
Printable View
thanks
The dll files contain binary implementation of the functions declared in h files and compiled from definitions contained in source code at MS.
They separate declaration from implementation because historically linking with Windows APIQuote:
They seperate the declarations from the definitions because they dont want people to know how the functions actually work.
And the dll files are the windows api, and the windows.h file is a part of the windows sdk.
Correct me if im wrong.
was designed as native C linkage which never had any mechanism for compiling type declarations into binary format. And still does not. :)
Please make sure you understand how declaration, definition and implementation differ from each other. Also please note, not only h files comprise SDK, but import libraries (lib) make another important part of it. :)
Yeah, I understand that a dll file is not source code, but actually source code already compiled into a language which the computer understands. And i think...
declaration = predefining a function, declaring it.
definition = the code inside a function which describes it behavior.
implementation = Is implementation when we use the function, when it is turned into code which the computer understands?
Okay, as long as we're clear with this, let's get back to your original question. What would be a reason for placing declaration to dll? And what bad in having it in h files?
Let's take COM model which really has type declarations embedded in dll server. To use interface function you need to extract the declaration and ultimately turn it to h file. Oops!
Let's take .NET model which also has embedded assembly metadata in executables. To use it you need a special runtime, CLR. Oops!
Every time you want type declaration supplied along with implementation you need a special infrastructure to deal with the one. While basic Platform SDK approach requires nothing special but the SDK installed only on developer's system, and no precious memory and disk space get spent for unnecessary type info on user's side. Well, as I said, the reason mainly is in Windows history and backward compatibility, amazing compatibility I would say. And having separate h files is a very, very moderate price for this benefit.
Ok. i appreciate your replies very much so :) So, from this forum ive learned that:
The windows.h file contains the declarations and the dll files contain the definitions (already compiled in computer language) of the functions within the windows API.
And the dll files are the windows api, and the windows.h file is a part of the windows sdk.
This is all i want to know at this stage. Am i right in saying this. Please answer with a simple yes or no, because at this stage more computer talk confuses me :D
It is yes about h files and declarations. And no, dll files do not contain definitions, as the term 'definition' (as well as declaration) is applicable only to source code and at compile time, but not an executable and runtime. It's really important to distinguish between these two and follow the terminology.
Ohhh I get you :)
They are actually the definitions, but when we use the word 'definition' we are talking about a definition in source code, when we refer to the definition in the dll file it is actually called an implementation because it have been compiled into a language the computer understands :D
Not quite.
The terms "definition" (and "declaration") have a very specific meaning in C/C++. They relate to how language constructs are physically organized in source code. To know the details you must learn the language.
Most Windows technologies, such as DLL and COM, are language independent. But if you're a C/C++ programmer and want to use any of these technologies you hopefully will be presented with some C/C++ source code to simplify your task. And this is where "definition" and "declaration" in the C/C++ sense enters the picture.