Origine of things !!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ghost0s
    New Member
    • May 2014
    • 8

    Origine of things !!

    Hi Guys i just want to know the answer of a "philosophi c" Question about C and maybe other PL's the Question is : if for example there is libraries to manage network that contains functions how those functions are made "programmed " how pc starts know the ip address for example how C program makes the processor wait for a signal from the networks card
    i hope you understand what im trying to say :p ??
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    There are two main types of libraries. The first is the static library and with these a copy of the library function has been injected into your executable file. Then you just call the function. You only need the ibrary when you build the program.

    The second type of library is the dynamic, or shared, library. Here you have to a)load the library at run time, b) call an OS function using the name of the function in the library you want to call, c) that function returns the address of the library function, d) you typecast the address into a function pointer of the correct type, and then e) you call the library function using the typecast function pointer.

    As to how the library functions themselves are coded by the OS programmers, you probably don't want to know. You are better off just learning how to use them.

    Comment

    • Ghost0s
      New Member
      • May 2014
      • 8

      #3
      Thnx man but i want to know how liberary functions themselves are coded :d

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        They are coded the same way you would code any other function.

        All you do is set your compiler project to build a library instead of an executable.

        Comment

        • Ghost0s
          New Member
          • May 2014
          • 8

          #5
          i think you didnt understand my question well what i want to say : how standard functions are coded for example source code of printf()

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            The source code for all standard C library functions is posted on the Internet. You can download it and browse through it.

            The code is different based on your operating system. Be sure to get the one that matches your OS.

            You might also check your compiler installation. Some of these tools include a copy of the Standard C Library source code.

            Comment

            • Ghost0s
              New Member
              • May 2014
              • 8

              #7
              Can you tell me why its different for each OS + i heard that the compiler it self contain binary codes for some instructions ??

              Comment

              • weaknessforcats
                Recognized Expert Expert
                • Mar 2007
                • 9214

                #8
                Each OS has an internal structure that is unique. The C for that OS must make system calls for that OS. C programs are not portable. Code compiled for Windows won't compile on Linux.

                It just the same as Ford cars can't use GM parts even though both cars have engines.

                Comment

                • Ghost0s
                  New Member
                  • May 2014
                  • 8

                  #9
                  im really enjoying this conv do you ?? + what about that compiler contains codes in a binary format for some orders is that true ??

                  THE BIG QUESTION IS HOW KERNELs ARE WRITTEN IN C or c++ and there is a c and c++ for each o.O

                  Comment

                  Working...