Questions tagged [libc]

The C standard library consists of a set of sections of the ISO C standard which describe a collection of headers and library routines used to implement common operations, such as input/output and string handling, in the C programming language.

The C standard library consists of a set of sections of the ISO C standard which describe a collection of headers and library routines used to implement common operations, such as input/output and string handling, in the C programming language.

There are many implementations of libc with different resource requirements, security goals, etc. With a typical tool chain the libc, compiler and OS work together to achieve some ISO, Posix or custom features/standards. Some libc implementation are only a subset of the ISO standard, but still full featured enough to be used in many applications.

Specific libc tags:

  • - the full Gnu Libc found on most GCC installs.
  • - a smaller micro-controller libc for resource constrained devices
  • - Android libc
  • - unhosted libc
  • - more modern lighter foot print libc

Websites

See also:

Do not confuse with , which is for the C++ programming language.

1076 questions
22
votes
1 answer

How did malloc and calloc end up with different signatures?

Possible Duplicate: Why calloc takes two arguments while malloc only one? There are lots of resources describing the difference in functionality between malloc and calloc, but I can't easily find one that describes the history behind the differing…
cdleary
  • 69,512
  • 53
  • 163
  • 191
21
votes
4 answers

What standard C library does Clang use? glibc, its own, or some other one?

I'm pretty sure glibc is the name of the standard C library implementation for gcc. But for LLVM/Clang I'm not sure. I've Googled to try to find if it comes with its own implementation of the whole standard C library, or whether they also use glibc.…
hippietrail
  • 15,848
  • 18
  • 99
  • 158
21
votes
2 answers

Close a FILE pointer without closing the underlying file descriptor

By using fdopen(), fileno() it's possible to open streams with existing file descriptors. However the proper way to close a file, once you've opened it with a stream is to fclose() the FILE pointer. How can one close the stream, but retain the open…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
21
votes
3 answers

gcc: Reduce libc required version

I am trying to run a newly compiled binary on some oldish 32bits RedHat distribution. The binary is compiled C (not++) on a CentOS 32bits VM running libc v2.12. RedHat complains about libc version: error while loading shared libraries: requires…
MonoThreaded
  • 11,429
  • 12
  • 71
  • 102
20
votes
2 answers

Why does time(time_t *) function both return and set the by-ref?

I've always been curious, why does the time(time_t *) function both return a time_t, and set the time to the passed in pointer? Example of returning the time: time_t myTime = time(NULL); printf("The time is now %s", ctime(&myTime)); Example of…
wjl
  • 7,143
  • 1
  • 30
  • 49
20
votes
3 answers

What is causing sprof to complain about "inconsistency detected by ld.so"?

I'm trying to use sprof to profile some software (ossim) where almost all the code is in a shared library. I've generated a profiling file, but when I run sprof, I get the following error: > sprof /home/eca7215/usr/lib/libossim.so.1…
Edward
  • 1,786
  • 1
  • 15
  • 33
20
votes
3 answers

Since the Standard C committee did not standardize a simple replacement for gets(), what should it be?

The gets function was first deprecated in C99 and finally removed in C11. Yet there is no direct replacement for it in the C library. fgets() is not a drop-in replacement because it does not strip the final '\n', which may be absent at the end of…
chqrlie
  • 131,814
  • 10
  • 121
  • 189
19
votes
2 answers

Why would it be illegal to inform about “abort”?

The GNU libc documentation of the abort function contains the following notice: Future Change Warning: Proposed Federal censorship regulations may prohibit us from giving you information about the possibility of calling this function. We would be…
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
19
votes
1 answer

What exactly SIG_DFL do?

What exactly SIG_DFL (defaut handler for signals) does? I'm interested in debugging SIGTSTP. It misbehaves slightly under weird conditions. I have suspicion it is doing something strange if one the threads is in the TASK_ININTERRUPTBLE state. Where…
George Shuklin
  • 6,952
  • 10
  • 39
  • 80
18
votes
2 answers

Linux function to get mount points

Is there a function (or interface; ioctl, netlink etc) in the standard Linux libs that will return the current mounts directly from the kernel without parsing /proc? straceing the mount command, it looks like it parses files in /proc
tMC
  • 18,105
  • 14
  • 62
  • 98
18
votes
5 answers

version `GLIBC_2.28' not found

I'm trying to install PyTorch on ARMv7(32-bit) architecture but PyTorch doesn’t have official ARMv7 builds so i tried this unofficial build. It installed successfully but when I import torch I get the following error >>import torch Traceback (most…
Ammarreda
  • 183
  • 1
  • 1
  • 4
18
votes
4 answers

Overlapping pages with mmap (MAP_FIXED)

Due to some obscure reasons which are not relevant for this question, I need to resort to use MAP_FIXED in order to obtain a page close to where the text section of libc lives in memory. Before reading mmap(2) (which I should had done in the first…
fons
  • 4,905
  • 4
  • 29
  • 49
17
votes
1 answer

Why is the address of __libc_start_main always the same inside GDB even though ASLR is on?

Breakpoint 1, 0x00007ffff7de8060 in __libc_start_main () from /usr/lib/libc.so.6 (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program:…
Chen Li
  • 4,824
  • 3
  • 28
  • 55
17
votes
1 answer

Why nm libc.so reports no symbols?

I've built a simple program like this: g++ application.cpp -o application.exe and then executed the command; ldd application.exe ... libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 ... I want to list all the symbols of the libc library: nm…
Alexey
  • 710
  • 3
  • 7
  • 19
17
votes
8 answers

How to write my own printf() in C?

Actually I am trying to write my own printf() in C by using varags. But I am not getting the correct solution for this. Can anyone help me out?
Rajesh M
  • 179
  • 1
  • 1
  • 3
1 2
3
71 72