C - Source code of functions in standard library [duplicate] - c

This question already has answers here:
C library source code [closed]
(6 answers)
Closed 4 years ago.
There is some way to see the source code of the functions contained in the C standard library and in the headers files like stdio.h?

https://www.gnu.org/software/libc/ there you go. Google is the best answer in some cases!

Depends on what you want to do with it. If you only want to get some idea then you can go with Gixuna's response. If you need to see your system's exact source code you have to get it from your distribution, they may apply patches, backports. For example if you have a debian system or derivates you can say:
apt-get source libc6
RPM based systems have different methods to get their SRPMs but I'm not familiar with those.
Also, be prepared that analyzing this source code will not be a walk in the park.

Related

how to view the functions and contents of a library [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to know how can I see the functions and the contents of a library in C language?
is nm libconfig.a | c++filt what you are looking for?
In general, you cannot see the source code of functions of a library (e.g. some libfoo.a or libfoo.so.* Linux files) compiled from C source code.
You should ask for the documentation of that library. If it is developed in house, you may need to discuss with colleagues.
I do like open source libraries like GNU libc or GTK. Because you are allowed to download their source code and study it.
Be aware of code obfuscation techniques and of Rice's theorem. Decompilation of binary libraries is legally forbidden in some countries.
But a lot of libraries are not open source.
On Linux, tools like objdump(1) or readelf(1) could be helpful.
Notice that some libraries (e.g. GNU lightning) are generating new functions and machine code at runtime. Hence the notion of function might be not as easy as you think.
On Linux, programs like my manydl.c or Bismon, or RefPerSys, or SBCL, are generating code at runtime: for manydl.c and Bismon it generates C code and dlopen(3) it after having compiled it as a plugin.
Jacques Pitrat's book Artificial Beings: the conscience of a conscious machine ISBN 978-1-84821-101-8 explains the interest of generating code at runtime. A relevant concept is partial evaluation.

Windows programmer moving to linux - Coding conventions [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have been developing for Windows for a long time, mainly WinApi (and .Net).
I'v started learning basic Linux, and I have some questions regarding the differences:
In Windows I have barely used the C Standard library.
If I needed an API, I would search MSDN and find the appropriate library\function.
From what it seems like, in Linux the C Standard library is EVERYTHING.
All the code samples I have seen used the standard library (Instead of using some Linux internal functions, like a Linux "CreateFile").
Is this really how writing "proper" linux code is done ? Using the C standard library ?
If I wish to read a file, or allocate memory are fopen\malloc the way to go ?
If the answer to my first question is yes (And I guess it will be)
The C standard library is POWERLESS compared to the powerful WinApi.
Lets say I wish to get a list of running process (CreateToolhelp32Snapshot) or create a thread or a process (CreateThread\CreateProcess), How should I do that in Linux ?
Documentation.
In Windows, all I need can be found in MSDN.
If I have a "how do I do" question (Like the questions above) where should I go ?
Where is my main source of documentation.
Thanks a lot,
Michael.
Perhaps you've forgotten that the Standard C Library isn't environment-specific, it specifies least-common-denominator functionality among all systems that can run C programs, and C runs on systems that don't even have processes.
If you want an API that provides consistent common GUI/multithread/etc. APIs, pick a likely-looking GUI/multithread/etc. API. You might start with Qt, it's quite comprehensive and produces good-looking, near-native UIs on a host of systems.
It's not generally considered polite to point this out, but most questions that get asked publicly are asked by people who lack the discipline to do even simple research. Once people can do that, they don't need to ask very many, and that's why what you see is so ... trivial. You're past that. For more options, you could start here.
For more general-purpose tools, the top hit on a search for important linux tools might be helpful.

C language compiler for new OS (theoretical questions)? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Let’s assume that I wrote a primitive bootloader using assembly language. The computer is still on real mode. Now I want to write a primitive kernel and shell using C language.
Questions:
1.Do I need to write a C Language compiler in assembly for this new OS or can I use a C compiler running on a different OS? I guess it could be both!
2.If I use a C compiler from a different OS, functions like printf () can be compiled to target the BIOS’s functions instead of the OS’s API to avoid dependencies?
3.If my bootloader switch the computer into protected mode the kernel will need to implement the equivalent to the BIOS functions?
4.Assuming a YES to question 3: If I use a C compiler from a different OS what is required to make it target the new OS kernel functions? Rewriting the headers files?
(EDIT) PD: These are theoretical questions. I don’t need specific details about the actual implementation. I just want to validate the concepts. Don’t feel obligated to answer all of them!
You can do either. I would strongly recommend to just use a standard compiler though. Writing a good compiler is very complex and time consuming.
As long as you do not have an implementation of the standard library just don't use it. You can tell C-compilers to assume that there is no standard library and write your own printf-like functions.
You lose access to the BIOS functions in real mode. If you need them you do need to reimplement them.
Not much change is required actually. Executables are incomplete and require to be linked against something that implements the used standard library functions and whatever other libraries used. All you need to do is link the executable against a (possible self-written) library that somehow implements the required functions.

Is there a .java source file for arrays in the JDK? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Source code for java array
There is a Java source file for java.lang.Object in the OpenJDK, which surprised me a bit, but I thought it was pretty interesting.
That got me wondering whether there is a source file for arrays (which after all are types of Object). Or is their behaviour hard-wired into the JVM somehow?
If such a thing existed, I would expect a lot of the methods to be native as I'm not sure how you could make it without being completely self-referential. But I'm curious as to whether it even exists.
See Where can I find the source code for Java arrays?
The poster also linked to this for OpenJDK

How to get call stack in c in windows? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How can one grab a stack trace in C?
In PHP it's debug_backtrace,is there such a function in c?
On Windows you can call the StackWalk64 function that is exported by DBGHELP.DLL. It is shipped with Debugging Tools for Windows (WinDbg) but according to this link, "The redistribution policies for these included DLLs were specifically designed to make it as easy as possible for people to include these files in their own packages and releases."

Resources