Skip Navigation
InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)TL
The C Programming Language

Everything related to the C programming language.

Members
709
Posts
9
Active Today
8
Created
6 yr. ago
  • The C Programming Language @lemmy.ml
    t0mri @lemmy.ml

    fatal error: dbus/dbus-arch-deps.h: No such file or directory

    im new to system programming, idk if thats the issuse. but according gcc, it can not find dbus/dbus-arch-deps.h and thats all i know. any idea about this issue?

     undefined
        
     program
    [I] tomri@artix ~ [1]> cat main.c
    #include <dbus-1.0/dbus/dbus.h>
    
    int main(void) { return 0; }
    
    
      
     undefined
        
    # error
    [I] tomri@artix ~> gcc main.c
    In file included from main.c:1:
    /usr/include/dbus-1.0/dbus/dbus.h:29:10: fatal error: dbus/dbus-arch-deps.h: No such file or directory
       29 | #include <dbus/dbus-arch-deps.h>
          |          ^~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    
    
      
     undefined
        
    [I] tomri@artix ~> ls -la /usr/include/dbus-1.0/dbus/
    total 216
    drwxr-xr-x 2 root root  4096 Jul  2 20:26 ./
    drwxr-xr-x 3 root root  4096 Jun 15 21:36 ../
    -rw-r--r-- 1 root root  2809 Jan 14 06:17 dbus-address.h
    -rw-r--r-- 1 root root  3470 Jan 14 06:17 dbus-bus.h
    -rw-r--r-- 1 root root 27018 Jan 14 06:17 dbus-connection.h
    -rw-r--r-- 1 root root  2909 Jan 14 06:17 dbus-errors.h
    -rw-r--r-- 1 root root 22076 Jun  8  2023 dbus-glib
      
  • The C Programming Language @lemmy.ml
    kixik @lemmy.ml

    open source structured thread safe logging library for C

    Is there a library for C, providing thread safe (high performance), and structured logging? An example for rust is the Tracing crate for rust (from Tokio). It should support several outputs as well.

  • The C Programming Language @lemmy.ml
    Jure Repinc @lemmy.ml

    GNU C Library 2.38

    cross-posted from: https://lemmy.ml/post/2650558

    Highlights:

    • More work on C2X features.
    • The strlcpy and strlcat functions have been added. They are derived from OpenBSD, and are expected to be added to a future POSIX version.
    • Support for x86_64 running on Hurd has been added.
    • CVE-2023-25139: When the printf family of functions is called with a format specifier that uses an (enable grouping) and a minimum width specifier, the resulting output could be larger than reasonably expected by a caller that computed a tight bound on the buffer size. The resulting larger than expected output could result in a buffer overflow in the printf family of functions.
  • The C Programming Language @lemmy.ml
    pizza_is_yum @slrpnk.net

    Enforce same size for arrays at compile-time?

    Let's say I have two arrays that have related data:

     undefined
        
    const char *backend_short[] = { "oal", "pa", "sdl_m" };
    const char *backend_long[] = { "openal", "portaudio", "sdl_mixer" };
    
    
      

    Does C support a way to "assert" that these two arrays have the same size? And failing compilation if they are different? I want a safeguard in case I'm drunk one day and forget to keep these synchronized.

    Thanks in advance.

    EDIT: I found a solution. Here are some enlightening resources on the matter:

  • The C Programming Language @lemmy.ml
    kawaiiamber @lemmy.ml

    Readline from stdin

    If one has POSIX extensions available, then it seems that defining _POSIX_C_SOURCE and just using getline or detdelim is the way to go. However, for source that is just C, here is a solution I've found from various sources, mainly here. I've also tried to make it more safe.

     undefined
        
    // Read line from stdin
    
    #include <stdio.h>
    #include <stdlib.h>
    
    #define CHUNK_SIZE 16 // Allocate memory in chunks of this size
    
    // Safe self-realloc
    void *xrealloc(void *ptr, size_t size)
    {
        void *tmp = realloc(ptr, size);
        if (!tmp) free(ptr);
        return tmp;
    }
    
    // Dynamically allocate memory for char pointer from stdin
    char *readline(void)
    {
        size_t len = 0, chunk = CHUNK_SIZE;
        char *str = (char *)malloc(CHUNK_SIZE);
        if (!str) return NULL;
        int ch;
        while((ch = getchar()) != EOF && ch != '\n' && ch != '\r') {
            str[len++] = ch;
            if (len == chunk) {
                str = (char *)xre
      
  • The C Programming Language @lemmy.ml
    copacetic @lemmy.ml
  • The C Programming Language @lemmy.ml
    copacetic @lemmy.ml

    The Spirit of C

  • The C Programming Language @lemmy.ml
    Ordoviz @lemmy.ml

    dwl is a dwm-like Wayland compositor based on wlroots

    I am not the author of dwl. Since dwl is based on wlroots (just like the popular Sway) it already supports making screenshots using grim and screencasts using wf-recorder.

    You can try out dwl from within your current WM. The default modkey is Alt. If you want to use the Super key, change #define MODKEY WLR_MODIFIER_ALT in config.h to #define MODKEY WLR_MODIFIER_LOGO and recompile. The default terminal emulator is kitty but you can change termcmd to alacritty if you want.

    Currently, only native Wayland applications run on it. You can enable experimental Wayland support for Firefox with MOZ_ENABLE_WAYLAND=1, see Running programs natively under Wayland in Sway Wiki.

    Do not hover over the edges of windows – this will crash dwl.

  • The C Programming Language @lemmy.ml
    randomrhino @lemmy.ml

    Looking for a programming buddy to study C together

    Hello fellow lemmys (or however do we call us?),

    as the title suggests, I am looking for someone who wants to learn the C programming language. I have a decent knowledge of computer science and of a couple of programming languages (C#, Java, Python). Currently, I am studying computer science in central/western Europe. In my opinion, studying together keeps each other motivated and is more efficient. In long terms, I hope, that we can contribute to open-source projects together and improve our code quality by reviewing each others code.

    If any of you has some interest in being my programming buddy, please message me or reply to this post. Preferably from a similar time zone (mine is UTC+01:00).

    Hoping for some replies

    Regards