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
39
votes
5 answers

Should I free/delete char* returned by getenv()?

char * val; val = getenv("ENV_VAR_NAME"); above is a code to get environment variable, will it cause memory leak if I dont free memory returned by getenv(char*) ? If no then…
SunnyShah
  • 28,934
  • 30
  • 90
  • 137
33
votes
2 answers

Are symbols from the C standard library reserved in C++?

This is a follow-up to a different question. The original question had other problems but I had to realize that the main one (according to CLang) was a redefinition of time as a different symbol while only nice C++ includes were used. So here is a…
Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252
32
votes
3 answers

How do I reimplement (or wrap) a syscall function on Linux?

Suppose I want to completely take over the open() system call, maybe to wrap the actual syscall and perform some logging. One way to do this is to use LD_PRELOAD to load a (user-made) shared object library that takes over the open() entry point. The…
Stefano Borini
  • 138,652
  • 96
  • 297
  • 431
31
votes
6 answers

Where can I browse the sourcecode for libc online (like doxygen)

Sometimes I want to look up the implementations of functions in the stdlib, I've downloaded the sourcecode, but it's quite messy. Just greping is not really suitable because of the many hits. Does anyone know a webpage doxygen style that has the…
monkeyking
  • 6,670
  • 24
  • 61
  • 81
31
votes
4 answers

Is MSVCRT under Windows like glibc (libc) under *nix?

I frequently come across Windows programs that bundle in MSVCRT (or their more current equivalents) with the program executables. On a typical PC, I would find many copies of the same .DLL's. My understanding is that MSVCRT is the C runtime…
Toybuilder
  • 11,153
  • 5
  • 28
  • 33
30
votes
2 answers

Why is argv parameter to execvp not const?

execvp is defined thus: int execvp(const char *file, char *const argv[]); Which precludes code such as this from being used: const char* argv[] = {"/bin/my", "command", "here", NULL}; execvp(argv[0], argv); Was this an accidental omission? Is it…
Jonathan Mayer
  • 1,432
  • 13
  • 17
29
votes
3 answers

Fatal signal 11 (SIGSEGV) code=2 on genymotion emulator not using NDK

My application does not use NDK. I am testing it on the GenyMotion Nexus 7 emulator and the problem is quite hard to reproduce and I still haven't figured out a correct way to reproduce it. Sometimes the application works fine for a long time and…
VM4
  • 6,321
  • 5
  • 37
  • 51
27
votes
2 answers

To infinity and back

There are mathematical operations that yield real numbers from +/- infinity. For example exp(-infinity) = 0. Is there a standard for mathematical functions in the standard C library that accept IEEE-754 infinities (without throwing, or returning…
srean
  • 2,578
  • 18
  • 18
27
votes
5 answers

Why the absolute value of the max negative integer -2147483648 is still -2147483648?

The result of abs(-2147483648) is -2147483648, isn't it? it seems unacceptable. printf("abs(-2147483648): %d\n", abs(-2147483648)); output: abs(-2147483648): -2147483648
Victor S
  • 4,021
  • 15
  • 43
  • 54
26
votes
4 answers

Replacing extrordinarily slow pow() function

We have a CFD solver and while running a simulation, it was found to run extraordinarily slow on some machines but not others. Using Intel VTune, it was found the following line was the problem (in Fortran): RHOV= RHO_INF*((1.0_wp -…
tpg2114
  • 14,112
  • 6
  • 42
  • 57
26
votes
8 answers

Small libc for embedded systems

I am looking for a small libc for embedded use with freertos on a ARM7 microcontroller. I have looked at newlib, but it is a bit too complex for my needs. Newlib calls malloc() in a number of functions (e.g. printf()), which is not good for small…
GT.
  • 901
  • 1
  • 6
  • 10
26
votes
5 answers

What does "f" stand for in C standard library function names?

What does f stand for in the name of C standard library functions? I have noticed that a lot of functions have an f in their name, and this does not really make sense to me. For example: fgets, fopen, printf, scanf, sqrtf and so on.
Erik W
  • 2,590
  • 4
  • 20
  • 33
24
votes
2 answers

What is the purpose of libc_nonshared.a?

Why does libc_nonshared.a exist? What purpose does it serve? I haven't been able to find a good answer for its existence online. As far as I can tell it provides certain symbols (stat, lstat, fstat, atexit, etc.). If someone uses one of these…
peachykeen
  • 4,143
  • 4
  • 30
  • 49
24
votes
2 answers

Why is the endptr parameter to strtof and strtod a pointer to a non-const char pointer?

The standard C library functions strtof and strtod have the following signatures: float strtof(const char *str, char **endptr); double strtod(const char *str, char **endptr); They each decompose the input string, str, into three parts: An…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
23
votes
3 answers

Is malloc/free a syscall or a library routine provided by libc?

If malloc/free is implemented as a library routine in libc, then is it implemented on top of the sbrk syscall or the mmap syscall, or something else? And to be general, does the function declared in sys/syscall.h contains ALL the system calls in the…
Pwn
  • 3,387
  • 11
  • 38
  • 42
1
2
3
71 72