CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23

Thread: API question :)

  1. #16
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: API question :)

    thanks

  2. #17
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: API question :)

    Quote Originally Posted by TpOreilly View Post
    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

  3. #18
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    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?

  4. #19
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    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

  5. #20
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    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

  6. #21
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    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

  7. #22
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    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

  8. #23
    Join Date
    May 2009
    Posts
    2,413

    Re: API question :)

    Quote Originally Posted by TpOreilly View Post
    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.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured