|
-
June 10th, 2011, 05:15 AM
#16
-
June 10th, 2011, 03:17 PM
#17
Re: API question :)
 Originally Posted by TpOreilly
Ok  so to summarise and closeee this thread:
The windows.h file contains the declarations and the dll files contain the definitions of the functions within the windows API.
The dll files contain binary implementation of the functions declared in h files and compiled from definitions contained in source code at MS.
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.
They separate declaration from implementation because historically linking with Windows API
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.
Best regards,
Igor
-
June 11th, 2011, 02:54 PM
#18
Re: API question :)
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?
-
June 11th, 2011, 03:55 PM
#19
Re: API question :)
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.
Best regards,
Igor
-
June 11th, 2011, 04:22 PM
#20
Re: API question :)
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
-
June 11th, 2011, 04:58 PM
#21
Re: API question :)
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.
Best regards,
Igor
-
June 11th, 2011, 06:26 PM
#22
Re: API question :)
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
-
June 12th, 2011, 01:15 AM
#23
Re: API question :)
 Originally Posted by TpOreilly
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 
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.
Last edited by nuzzle; June 12th, 2011 at 11:47 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|