Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Filter by
Sorted by
Tagged with
3 votes
0 answers
46 views

Is this a well-defined way to access bitfield bits by index in C11

The order of bits in C11 bitfields is implementation-defined, and so is any padding in between them. This makes it difficult to access the bitfields by index at runtime, even though most ...
jpa's user avatar
  • 12.4k
1 vote
1 answer
59 views

_Generic in C is making me go insane

Take a look at my code: #include <stdio.h> #include <stdlib.h> #define add_int(a, b) ((a) + (b)) typedef struct matrix { int** data; int n_rows; int n_columns; } matrix; ...
PsquareJ Lol's user avatar
2 votes
1 answer
80 views

Trying to learn how getchar works

I am encountering a problem inside a while loop that is embedded in a for loop iterating through a struct of arrays. The issues I am coming across is before the array iterates again, I want to have ...
Zachary Vandermude's user avatar
Advice
1 vote
14 replies
198 views

Is there a reason why signed integer is used for the ssize_t?

From the man pages, I found that size_t has the range of 0 to SIZE_MAX, and ssize_t has the range of -1 to SSIZE_MAX. So, after printing those values on a 64bit system, I have the following results: ...
sat0sh1c's user avatar
1 vote
0 answers
57 views

How To Create Progress Into Thread In UEFI For Multitasking [closed]

UEFI By Default Starts OS With Single Core And Is Harder To Multitask In UEFI Using Start Progress In Thread. I am making OS Form Scratch For Multitasking But There Is No Option To Multitask In EDK 2 ...
First Person's user avatar
0 votes
1 answer
132 views

Input memory leak? [duplicate]

In my homework assignments I've got a task to get an input using scanf() of an integer number and check if its a positive negative or zero. I've coded this: #include <stdio.h> int main() { ...
CallMeEdwin's user avatar
Best practices
0 votes
8 replies
119 views

In C with stdarg, how can I pass a va_list to another function safely?

man stdarg shows, under the va_args macro description: If ap is passed to a function that uses va_arg(ap,type), then the value of ap is undefined after the return of that function. If we look at ...
m0d1nst4ll3r's user avatar
2 votes
1 answer
129 views

Accurate computation of the inverse gamma function with the standard C math library

The inverse of the gamma function over the reals is multivalued with an infinite number of branches. This self-answered question is about the principal inverse of the gamma function, Γ0-1(x), whose ...
njuffa's user avatar
  • 27.1k
Advice
0 votes
3 replies
91 views

Misunderstanding System V x86_64 ABI

My question is how this structure passed and returned from function? struct S { int a[5]; }; I read ABI. As far as I understand if the size of structure less then 64 bytes it will separate to ...
chav1s's user avatar
  • 41
1 vote
0 answers
44 views

Why doesn’t rlgl 2D drawing appear when using Raylib Camera2D?

I'm trying to batch some textures together in raylib (2d game) and so it tried using the 2d rlgl and for some reason that I can't figure out why nothing is getting drawn. I looked at examples and ...
ישי סירקיס's user avatar
7 votes
1 answer
121 views

If I start two strictly CPU bound threads bound to the same CPU, and one is SCHED_IDLE, why does it ever schedule?

If I start two threads bound to CPU 0, where one is SCHED_IDLE, then why is it ever scheduled when the other thread is CPU bound at either normal priority, or at SCHED_FIFO? For SCHED_FIFO I get it, ...
Thomas's user avatar
  • 4,416
1 vote
0 answers
65 views

WebKit2 Transparent window ghosting/after-image after DOM updates

I have successfully created a GTK window, made it paintable, created a WebKitWebView context, made sure it was completely transparent, and managed to render only the elements of the DOM inside the ...
beyluta's user avatar
  • 21
3 votes
2 answers
106 views

Code is returning "[C Kernel] Executable exited with code -11", don't know what's wrong with it?

I'm working on this piece of code as part of my coursework, ideally any advice I get for this would be educational in some way; I don't want an exact answer, just need someone who knows more than I do ...
Eve's user avatar
  • 33
1 vote
1 answer
119 views

Why does my multithreading/pointers code print random values?

My code should print the numbers given as command line arguments. Instead it prints random-looking values. What is going on and how can I fix it? #include <stdio.h> #include <pthread.h> #...
user31884282's user avatar
-2 votes
3 answers
202 views

Why does float f = 3.14; and float f = 3.14f; print the same value in C even though one is double and the other is float?

I am confused about the following behavior in C. #include <stdio.h> int main() { float a = 3.14; // literal is double float b = 3.14f; // literal is float printf("%f\n"...
Recent Job Circulars's user avatar
-4 votes
0 answers
84 views

Tool to visualize C pointers, structures, enums, typedefs, etc [closed]

I'm working on an embedded (uBlaze running FreeRTOS on an FPGA) project in C, and there's a complicated network of structures, pointers, and "objects"* with complicated interdependence. Part ...
user31875001's user avatar
1 vote
2 answers
89 views

How to handle N buttons with separate actions in pure C on Arduino without writing N ISR wrappers?

I'm working on an Arduino project in pure C with multiple buttons. Each button has a different action associated with it, and I want to handle button presses using interrupts. Currently, the typical ...
Cufa Niello's user avatar
-3 votes
0 answers
56 views

Trying to use ncurses getch or scanw to capture user input to confirm user permission for file overwrite

I'm trying to use ncurses.h in C to capture the user's key press to confirm if a file should be overwritten or not, for a terminal based audio recording/playing program. The way I've implemented is I ...
Sanjay Menon's user avatar
4 votes
2 answers
103 views

Is it possible to have a combine() function for CRC64/NVME

AWS S3 uses CRC64/NVME for its default checksum algorithm. I need to send a trailing CRC64/NVME checksum. The kicker is that I am middleware. There are multiple threads that are sending bytes. I ...
Justin James's user avatar
1 vote
1 answer
35 views

kretprobe executes the entry_handler function, but it doesn't execute the handler function

I'm interested in the arguments and the return value of the function __bread_gfp, so what i did was install an entry_handler for the arguments and a handler for the return value. Here's my code: #...
Damiano De Orazi's user avatar
-2 votes
1 answer
52 views

Not able to get Segger SystemView working on Freertos on STM32L0 in STM32Cubeide

I'm trying to get the segger systemview working on a STM32L073RZ nucle board with FreeRTOS. I have verified that freertos is working fine with the MCU as I could create 2 tasks and run them ...
SumKha's user avatar
  • 47
Advice
0 votes
2 replies
56 views

How do I upgrade the cygwin package

I have cygwin 3-0-0 version and wish to keep all packages under the cygwin and only upgrade 3 packages, but i am confused on what to select. I need to upgrade them for CVE fix( xz utils and gawk) I ...
aΨVaN's user avatar
  • 1,156
3 votes
0 answers
71 views

Problems justifying text in GTK

System: Linux, Language: C, Toolkit: GTK I am working to create an emulator for an embedded machine's display. The display is a smart 800x400 pixel RGB display. The machine sends commands to control ...
Code Dalek's user avatar
-6 votes
1 answer
117 views

display different combination in c [closed]

Idk the structure to drive this. it should display like 00 01, 00 02, ... 01 99, ..., it finishs by 98 99.. just help me with the algorithm please void ft_print_comb2(void) { char a,b,c,d; a='...
Elhirah NyItokiana's user avatar
-1 votes
0 answers
104 views

How efficient are pipes and threads in C compared to regular function calls or pure sequential code? [closed]

I’m currently studying Operating Systems at college, and my professor has started teaching us about threads and pipes in C. His teaching style is very practical — he expects us not only to understand ...
Matheus Ferreira's user avatar
-1 votes
0 answers
80 views

controlling and managing dependencies in projects

#include <SDL2/SDL.h> Like everyone I typed brew install sdl2 but still gives me the error --cannot open source file "SDL2/SDL.h" Is there any magical way of controlling every ...
Alpcan Alper's user avatar
1 vote
5 answers
177 views

How can I tell my compiler or linker, that some symbol reference is only necessary for some function?

Suppose I'm working a library; say it's in C for simplicity. This library exposes and defines two functions: f(), which calls an auxiliary function aux(), declared but not defined by my library. g() ...
einpoklum's user avatar
  • 137k
0 votes
1 answer
167 views

Identifying a failed null check

I am working on a function that must read one line at a time from a file, give the file descriptor of said file as input. Here is my get_next_line function, and helper functions on top of it # include ...
Simeon Sutarmin's user avatar
3 votes
0 answers
74 views

Can I modify host data after cudaMemcpyAsync

Can I modify host data in host_data_ptr after the following ? cudaMemcpyAsync(device_data_ptr, host_data_ptr, size, cudaMemcpyHostToDevice, ...
YSF's user avatar
  • 41
3 votes
2 answers
93 views

Why do I get a Run-Time Check Failure #2

Im new to C Programming and the Windows API im getting "Run-Time Check Failure #2 - Stack around the variable 'pMyStringAdress' was corrupted." after compilation in Visual Studio Thats my ...
reiner's user avatar
  • 33
3 votes
2 answers
119 views

How can I correctly load the kernel to its canonical high address space

I am working on a small os with a custom boot loader targeting BIOS. For this, I need to map the kernel to its canonical high address space (0xFFFFFFFF80000000) and jump to its entry point. For this, ...
Holz's user avatar
  • 133
0 votes
0 answers
48 views

wrong transformes for model loaded with assimp in opengl

Im trying to apply the model's transforms by walking the node heirarchy, but the poses are wrong (im not trying to animate it, just load it in a pose by using the transforms given in the gtlf file) ...
Muaaz Khan's user avatar
Best practices
1 vote
7 replies
157 views

Memory allocation when using a linked list

So I'm making a linked list for one of my school assignments in C. I found this website that has some helpful code snippets, and I noticed that they use malloc() to allocate more memory every time ...
Klumpy7's user avatar
  • 123
1 vote
1 answer
95 views

Libav* encoding to FLAC results in MD5 Signature Mismatch

I am trying to learn how to use the FFmpeg libav* libraries but have encountered an issue when encoding to FLAC audio. Running FFmpeg 5.1.7 I have copied the transcoding.c example from https://www....
SomeGuy's user avatar
  • 19
0 votes
1 answer
118 views

Manual strstr implementation in eBPF on kernel level

I am trying to implement a manual implementation of strstr in eBPF but cannot get past verifier. Before starting, I know there is an existing bpf_strstr() implementation, but it's on 6.17+ linux ...
Stefan Misu's user avatar
6 votes
1 answer
210 views

MSVC doesn't follow NAN convention

The following code prints 1.000000 when compiled with gcc (trunk) 1.000000 when compiled with clang (trunk) NAN when compiled with msvc (latest) #include <stdio.h> #include <math.h> #...
gberth's user avatar
  • 876
2 votes
2 answers
143 views

Simple C malloc question that prints garbage on multiple invocations [closed]

I'm refreshing my C skills (been decades) and ran across something I don't quite understand. I'm working on some code that involves a lot of bit shifting, masking, etc. I have one function that ...
Maryann's user avatar
  • 39
-1 votes
3 answers
67 views

Trying to read character and turn it into a string

static char* convert_to_string(const volatile uint8_t *ch) { static char read[40]; // static so pointer remains valid after return uint8_t i = 0; while (*ch != ESC || *ch != END_OF_TEXT ||...
Maaz Madha's user avatar
Advice
0 votes
3 replies
87 views

Restrict keyword and pointers to pointers

I'm in C and I have an int ** (2 dimensional array, it's basically a matrix, it's actually set up a little bit complicated but there's no internal aliasing, so it's not relevant). is this int** ...
Snark's user avatar
  • 1,674
2 votes
2 answers
77 views

mallopt(M_PERTURB) does not perturb the memory on free

I am trying to catch memory-related bugs such as use-after-free by mallopt(M_PERTURB, <value>). According to the doc, the memory will be initialized to value when it has been released by free. ...
davidhcefx's user avatar
3 votes
1 answer
89 views

PowerPC/PPC64: The actual bit-ordering/numbering of the POWER9 registers from the programmer POV

Consider the following MSR register (the register's value is for the sake of example): 0x0400000000000000 -> MSR[58] = 1 -> Instruction Relocation for MMU is activated. Now imagine I want to ...
manili's user avatar
  • 648
1 vote
0 answers
107 views

STM32H7 UART RX not receiving data while TX works

TX works and prints info in console (I use Putty) but when I send on STM and echo I don't receive anything (and when I write symbols in console they don't appear). Baud rate and other config settings ...
Крафти's user avatar
Advice
0 votes
5 replies
84 views

How to assign unique elements to different indices?

I've been working on a program that prints out each word, their number of occurrence's and percentage of the number occurrences over total length of the sentence. As you can imagine I had to create a ...
Mehmet emi Sevim's user avatar
5 votes
1 answer
106 views

Symbol#to_s, Array#last, Time.now undefined or no-ops when evaluated using Ruby 3.x C API

For several years I've been using the Ruby C API to add the ability to use Ruby code in my C text editor (a variant of MicroEMACS). This has been working well in Linux Mint 21 (essentially the same ...
bloovis's user avatar
  • 53
2 votes
1 answer
76 views

How do I portably parse a JSON file using libjq?

Consider the following code snippet based on libjq. #include <stdio.h> #include <stdlib.h> #include <jq.h> #include <jv.h> int main(void) { jq_state *jq = jq_init(); ...
merlin2011's user avatar
  • 76.4k
Best practices
0 votes
2 replies
87 views

Do I need a __DMB() memory barrier between two ISRs on a single-core Cortex-M (e.g., STM32H7)?

On a Cortex-M7 microcontroller, I have two interrupt service routines running at different priorities(in a baremetal environment) : IRQ1 runs at 20 kHz (higher priority). IRQ2 runs at 4 kHz (lower ...
tonyjk's user avatar
  • 35
Best practices
1 vote
7 replies
121 views

Is there way to remove coredump generation for SIGQUIT for C program

I have automated tests for fairly complex software, which send SIGQUIT signals at program startup. If the signal arrives before the handler is installed, a coredump is generated, causing the test to ...
se_pavel's user avatar
  • 2,208
4 votes
1 answer
195 views

Why when I build my Python library from C code, the Python functions don't work

I'm trying to build a Python library from C code. I'm on macOS. When I only build the .so file and link it in Python like this, all the functions work as intended: import sys sys.path.append("...
Jean1000's user avatar
0 votes
1 answer
118 views

Why Cuda threads are repeating same task?

I have a coded my simple CUDA ZIP password cracker but it seems that it prints same password for a number of times and i couldn't figure out why and this is weighing down my program. Here is the full ...
actgroup inc's user avatar
0 votes
0 answers
98 views

Program freezes when assigning to a struct field in my HTTP parser [closed]

I'm building a simple HTTP parser in C using a state machine. (Im just a begginer and i just started with C) Everything works fine ( parsing the method, URI, version, and headers ) except when I try ...
JUAN DIEGO DIAZ ACEVEDO's user avatar

1
2 3 4 5
8166