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
7
votes
1 answer

How to use patchelf with --set-interpreter?

I'm trying to do the following: Change the libc of a simple test.c from the system default (Debian 9.11, libc-2.24.so) to libc 2.27. This is my attempt: user@pc:~/patchelf_test$ cat test.c #include int main(int argc, char **argv) { …
uw2pw
  • 71
  • 1
  • 2
7
votes
1 answer

Why does fseek use read() system call?

I'm trying to understand the glibc implementation of fseek. To do so, I downloaded the glibc source code and tried to understand its function execution order. I found the fseek implementation in libio/fseek.c. Basically, it calls the function (or…
MajorasKid
  • 733
  • 2
  • 5
  • 24
7
votes
2 answers

fgets(), signals (EINTR) and input data integrity

fgets() was intended for reading some string until EOF or \n occurred. It is very handy for reading text config files, for example, but there are some problems. First, it may return EINTR in case of signal delivery, so it should be wrapped with loop…
firk
  • 339
  • 2
  • 10
7
votes
3 answers

Redefining functions lin libC

Assume the following simple C code: file1.c #include char* gets(char* i){ return i; } which is redefining the libC native function gets. This compiles fine with gcc file1.c. My question is howcome the linker isn't complaining about…
Alex
  • 71
  • 1
7
votes
7 answers

Is there any ordinary reason to use open() instead of fopen()?

I'm doing a small project in C after quite a long time away from it. These happen to include some file handling. I noticed in various documentation that there are functions which return FILE * handles and others which return (small integer)…
staticsan
  • 29,935
  • 4
  • 60
  • 73
7
votes
1 answer

Can docker solve a problem of mismatched C shared libraries?

I am trying to run some haskell code on an ubuntu (18.04) host, which was compiled on my laptop. host: 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux laptop: 4.14.74-1-MANJARO #1 SMP PREEMPT Fri Oct 5…
ocstat
  • 189
  • 3
  • 8
7
votes
2 answers

Passing Vec from Rust to char** in C

I've been trying to write a shell in Rust that links directly to the libc library. I've used a Vec to hold the arguments to be passed to execvp(), but it seems that my conversion to char ** has not been successful. Upon execution, all the…
Jianzhong Liu
  • 85
  • 1
  • 7
7
votes
1 answer

How to compile with an another libC on Linux? (gcc)

I want to compile my C program with an another C library like dietlibc or musl. What gcc option should I use for this purpose?
meridj
  • 81
  • 2
7
votes
2 answers

Is there a Rust equivalent to the clock function in C++?

I'm trying to test the efficiency of parts of my code, and C++ has a clock function in ctime that allows measurement of the processor time consumed by the program using the clock_t type. Is there some Rust equivalent that isn't just measuring the…
Harvey Adcock
  • 929
  • 1
  • 7
  • 16
7
votes
1 answer

Linux syscall, libc, VDSO and implementation dissection

I dissects the syscall call in the last libc: git clone git://sourceware.org/git/glibc.git And I have this code in sysdeps/unix/sysv/linux/i386/sysdep.h: # define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \ LOADREGS_##nr(args) …
tutuen
  • 313
  • 1
  • 3
  • 13
7
votes
2 answers

Using an alternative libc in a cmake project

I have a C/C++ project that is built using CMake. While trying to compile a static binary, I've run into issues with different GLIBC versions on my computer and the target machine. In a different question on SO, the accepted answer to a similar…
janoliver
  • 7,744
  • 14
  • 60
  • 103
7
votes
3 answers

Faster math library than glibc on x86_64/linux?

Is there a drop-in replacement to glibc's libm (and headers?) for x86_64-linux that is faster?
user3141592653589
7
votes
2 answers

-Werror=format: how can the compiler know

I wrote this intentionally wrong code printf("%d %d", 1); compiling with g++ and -Werror=format. The compiler gives this very impressive warning: error: format '%d' expects a matching 'int' argument [-Werror=format] As far as I can see, there's no…
XPlatformer
  • 1,148
  • 8
  • 18
7
votes
1 answer

is there any api for linux iptables , so that my program can add firewall rules

I am writing an application using libc, for that am in search of an api for iptables so that i can add firewall rules using my program .is there any available set of api to do this.
cc4re
  • 4,821
  • 3
  • 20
  • 27
7
votes
1 answer

Setting a watchpoint on errno in gdb

I'm trying to find out when errno changes. At first, I tried "watch errno" in gdb, which led to the error Cannot find thread-local variables on this target I was able to fix this by compiling with "-pthread". However, it still doesn't work and I…
Hermann Speiche
  • 894
  • 1
  • 9
  • 16