Thread: C standard library on Windows platform

  1. #1
    Registered User
    Join Date
    Mar 2015
    Posts
    10

    C standard library on Windows platform

    I'm sorry for such a simple question ...

    I'm studying C with some books and all of them mentioning about the C standard library.
    But, when I look at the MSDN site there is no library reference for C. There is CRT - C Runtime Library.
    Is CRT the Microsoft implementation of the standard C library?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Is CRT the Microsoft implementation of the standard C library?
    After a fashion. The standard C library is part of the CRT.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    120
    To add to what Prelude said: Library writers sometimes add implementation specific functionality to their libraries in adition to what the C standard declares. If you want the maximum portability I sugest not using functions which are not in the standard, but there might be some tools in a specific implementation that may be helpful to you.

    In the documentation itself you should see some functions marked as non-standard if they are not a part of the C standard (or at least they should be, I don't know how MSDN handles things), but all the standardized functions will be available (or should be), and produce equal results (other than undefined behavior), in any C library.

  4. #4
    Registered User
    Join Date
    Mar 2015
    Posts
    10
    Thank you all.

    As far as I can see, although there are .lib files in CRT, we use standard header files names in our source files (like stdio.h) for using functions in CRT.
    Can we use .lib files directly in our source files?

    And, I need to see some simple examples to understand static and dynamic library files ... can you please advise me a book for understanding of creation of .lib and .dll files and seeing their usage in my source files?

  5. #5
    Registered User
    Join Date
    May 2014
    Posts
    121
    You usually never deal with DLL files directly in your code. You can manually load and unload DLLs if you want to but that is usually done by the linker when you compile your project (in Visual Studio).

    .lib files are a dubious creature in Windows since they are used for both static libraries and as a way for the linker to automatically load DLLs. That's why DLLs are often accompanied by a .lib file since otherwise you would have to create code yourself that loads and unloads it.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by OzanK
    As far as I can see, although there are .lib files in CRT, we use standard header files names in our source files (like stdio.h) for using functions in CRT.
    Typically, unless you specify otherwise or in some special cases (e.g., when using <math.h>, the need to link with libm on some platforms with gcc by passing -lm as a compiler option), you will link to the CRT.

    Quote Originally Posted by OzanK
    Can we use .lib files directly in our source files?
    That would not make sense. In your source files, what you need are the function declarations, struct and other type definitions, certain constants, etc, that are available by including the appropriate headers.

    Quote Originally Posted by OzanK
    And, I need to see some simple examples to understand static and dynamic library files ... can you please advise me a book for understanding of creation of .lib and .dll files and seeing their usage in my source files?
    Given a specific compiler toolchain, you can probably find this information online by searching.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Mar 2015
    Posts
    10
    Thanks a lot for the replies.

  8. #8
    Registered User
    Join Date
    Mar 2015
    Posts
    10
    Everything is so mixed for a beginner especially if he is over 40 .... I would like to ask one more question.

    I'm planning to write command line C programs for 32 and 64 bits Windows platforms ... and I will use Visual Studio compiler for compiling my programs.
    For this target, I think that I should master C language, Microsoft C Runtime Library and the Visual Studio C compiler options.
    Is there any other thing I should study for my target?

    Thanks a lot.
    Last edited by OzanK; 04-17-2015 at 01:09 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 08-28-2011, 10:05 PM
  2. Platform Detection Library?
    By Jesdisciple in forum C Programming
    Replies: 23
    Last Post: 01-16-2009, 09:23 PM
  3. platform specific API or C standard API
    By George2 in forum C Programming
    Replies: 1
    Last Post: 11-12-2007, 01:32 AM
  4. Cross platform XML library
    By Josh Kasten in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2007, 04:04 PM
  5. Standard Library file io under windows
    By willkoh in forum Windows Programming
    Replies: 1
    Last Post: 09-24-2005, 09:02 AM