tags:

views:

98

answers:

5

when you need to use a function you include a header file but wheres the function code is defined?

A: 

The source code is not published.

Linux publishes its source code, because it is open source.

Windows is owned by Microsoft; the code is privately owned and MS chose not to publish the code.

If the code was published, third parties could in principle compile Windows for themselves, which would be they would no longer need to buy copies from Microsoft.

Blank Xavier
There are those that argue that there's no need to buy copies from Microsoft as it is.
Ignacio Vazquez-Abrams
It's not always about Linux vs. Windows. The guy just wants to know where the code referenced in the header files lives.
Adam Crossland
-1 for assuming function code means source code rather than object code to link
Jeff Yates
Well said, Jeff.
Adam Crossland
For those interested in source there's always WINE (http://www.winehq.org/) and ReactOS (http://www.reactos.org/en/index.html)
PP
"function code is defined" - defined has with regard to code a specific meaning in C and that made me believe he was asking about source code.
Blank Xavier
-1: nobody asked about the source code.
John Saunders
The guy said, in broken english, 'function code is defined'. My best guess was that he was talking about source code. Can we stop being post Nazis now? :-/
Blank Xavier
A: 

In the source code of some library, hence it is exposed as symbol in some library to wether statically/dynamically link against.

If it is closed source (like win32 API) you won't see its source code as long as you aren't working for the MS Windows team I suspect.

anselm
what does the question have to do with source code???
erikkallen
The question was where the Windows functions are *defined*. You know the difference between a *definition* and a *declaration* in C?
anselm
+5  A: 

Dave, the code lives in the various and many DLL files in your Windows\system32 directory.

Adam Crossland
I second this. Almost all of the Windows API calls are part of a DLL. When you link your code you usually load a library which is responsible for loading the appropriate library. See http://en.wikipedia.org/wiki/Dynamic-link_library#Import_libraries
PP
+1  A: 

Well as explained above you are in the hands of microsoft. You can always look at the msdn http://msdn.microsoft.com. For most API functions you can find some information at the bottom. For most function you get from there:

Minimum supported client
Minimum supported server
Header
Library
DLL
Unicode and ANSI names

mkaes
+4  A: 

The actual code that implements the Win-32 API are defined in various DLLs on your system. These DLLs have names like kernel32.dll, comctl32.dll etc. You will find them in C:\Windows\System32.

What generally happens is that you link your code with kernel32.lib etc. that have a little code to dynamically load the DLLs when your program starts. This allows Win32 API functions to directly call into the DLLS.

Cthutu