Skip to main content
Filter by
Sorted by
Tagged with
2 votes
0 answers
64 views

I am including OCR with Leptonica and Tesseract capi.h in my C project. For regular images loaded as Pix, all is good, but for multipage TIFFs loaded as Pixa, I get the following compiler error: ocr.c:...
Torsten Römer's user avatar
2 votes
0 answers
36 views

I am benchmarking several very simple CUDA SGEMM kernels on an NVIDIA Hopper GPU (H800, sm_90), and I observed something that I do not fully understand. I have two kernels that, to my understanding, ...
plznobug's user avatar
  • 163
4 votes
1 answer
62 views

Trying to reproduce buffer overflow on Ubuntu 24 for learning purposes. So the goal is to call call_me_twice second time by passing its address into input string. $ cat bof.c #include <stdio.h> ...
Slimboy Fat's user avatar
0 votes
0 answers
80 views

I've been reading chapter 7 on Performance in The Practice of Programming from 1999 by Brian W. Kernighan and Rob Pike. On page 172, they show the following commands for profiling a C program: % cc -p ...
Patrick Bucher's user avatar
-4 votes
0 answers
81 views

For some reason when I build such a simple program in Visual Studio 2022: #include "cuda_runtime.h" #include "device_launch_parameters.h" #include "cuda.h" #include <...
Brain_driver_not_found's user avatar
Advice
0 votes
1 replies
27 views

Recently, I have just started to get acquainted with the bluez protocol stack. I would like to know how the version of bluez corresponds to the official Bluetooth specification version. For instance, ...
Alex's user avatar
  • 1
6 votes
1 answer
101 views

After reading a draft of the c23 standard (n3220), I was trying to gain an understanding of ungetc by writing a simple example. In This Example I: fopen a file named file.txt for updating, either ...
timmy george's user avatar
1 vote
0 answers
38 views

I am trying to learn some operating system engineering so I came about MIT's operating system engineering course which has been wonderful so far. The problem I'm having is with the second problem read-...
아이스크림은메로나's user avatar
10 votes
3 answers
202 views

Often, I'd like to chain preprocessor conditionals involving __has_include (defined in C++17 and C23, and supported in earlier versions as an extension by many compilers (GCC 4.9.2 and up, and Clang ...
Noam Elul's user avatar
  • 806
Advice
0 votes
5 replies
101 views

I have the following C code (an MWE): #include<time.h> void fun() { asm("arg1:"); struct timespec const a = { .tv_sec = 10, .tv_nsec = 0 }; asm("call_nanosleep:"); ...
user10732's user avatar
1 vote
3 answers
228 views

My expected outcome is that I'm able to compare floats up to the sixth decimal point. The actual results are that they that it's incorrect, only sometimes though. Bonus if you can tell me why without ...
Etetherin's user avatar
5 votes
1 answer
141 views

I am work a mature codebase, one of the signs of its age is lack of consts which make the code difficult to reason about when refactoring. I have found a function which takes an argument as a mutable ...
Dominik Kaszewski's user avatar
Advice
1 vote
6 replies
107 views

I''m writing a cache-friendly program with a lot of random read-writes and let's say I use a _mm_prefetch _MM_HINT_T0 intrinsic to load some data into L1 cache. Then I wanna prefetch another things to ...
Brain_driver_not_found's user avatar
3 votes
2 answers
141 views

I'm a beginner with the Windows API and C Programming, I am trying to get the file size from my files, but my output is not so as expected. That's my code: #include <Windows.h> #include <...
reiner's user avatar
  • 63
3 votes
1 answer
138 views

I’m currently learning about data structures and algorithms (DSA) by reading the book “Learning JavaScript Data Structures and Algorithms – 2nd Edition” by Loiane Groner. I am implementing the DSAs in ...
Gabriel França's user avatar
5 votes
2 answers
136 views

I have a simple struct in C and I used typedef to create an alias (db) for it: typedef struct { char* name; } db; I then allocated memory on the heap for a pointer: db *a = malloc(sizeof(db)); a-&...
Mahdi Hosseini's user avatar
Best practices
0 votes
15 replies
161 views

Working in C with a library which has a very complicated set of return codes. I have a function which takes a library's error code and converts it into my error code. If the resulting "my" ...
White Owl's user avatar
  • 1,524
5 votes
1 answer
168 views

I’m building a shared-memory, event-driven allocator on Linux with: Multiple producers, single consumer (MPSC) Variable-size allocations from a shared memory pool When memory is unavailable, ...
Mohammad's user avatar
  • 221
Best practices
0 votes
9 replies
136 views

I'm creating a program that involves showing the battery percentage and charge status. I want to be able to have the program update as close to instantly as I can get. Every example I could find ...
oosh's user avatar
  • 356
24 votes
4 answers
2k views

C23 added the classification macro iszero for testing whether an argument value is zero, specified like: int iszero(real-floating x); What is the difference between using iszero(x) and writing x == 0?...
Jan Schultke's user avatar
  • 44.4k
Advice
0 votes
0 replies
89 views

Karel is placed in a world that contains a binary tree represented by beepers. Each node of the tree is located on a single field and may contain one or more beepers. The root of the tree is placed ...
Samuelso's user avatar
5 votes
1 answer
168 views

I'm working on a C99 project that is required to follow the MISRA C:2012 standard. Whenever I use an enumeration type, I get a violation of rule 10.4 or 10.5. As a static analysis tool, I use the code ...
Jelly00's user avatar
  • 53
1 vote
0 answers
107 views

I am trying to make a Dronecan GNSS-node from a stm32g4, using fdcan but with a classic can implementation(8byte payloads), I use the canard lib for managing the node. but when trying to receive the ...
mark de gast's user avatar
4 votes
1 answer
247 views

I am trying to compile my code with openssl library. My code is printf then the program received SIGSEGV signal. Code of test.c: #include <winsock2.h> #include <openssl/ssl.h> #include <...
Orang Keren's user avatar
1 vote
0 answers
123 views

I'm new to CUDA, and I can't see where's the mistake in my kernel. Upon comparing it with the result from my professor, the difference was extremely small, with the pixel average being off by 0,0039. ...
peng33's user avatar
  • 11
1 vote
0 answers
93 views

I am getting the following error (debugger output) when i try to do "ST_LINK: attach to application" in vscode. I have no idea what is going on. Any help is greatly appreciated. I use WSL ...
federico1234991's user avatar
14 votes
3 answers
2k views

Take a look at the function SHA1Transform taken from an SHA1 algorithm on Github. Assuming SHA1HANDSOFF is defined, the function looks like this: void SHA1Transform( uint32_t state[5], const ...
Andreas's user avatar
  • 10.6k
1 vote
2 answers
204 views

I want to do pure type punning without memcpy in C using pre-allocated page which I made with mmap() on Linux, because I understand the architecture and how physical ram works, alignment & ...
abrar's user avatar
  • 21
2 votes
1 answer
168 views

If I wanted to replace large chunks of an array in C with items from another list, are there any solutions that don't involve for loops or writing code like the following? int64_t foo[size]; foo[value]...
Chubbachoo's user avatar
2 votes
1 answer
124 views

I have written a CFD code which I POC'd in Python. In order to accelerate the computationally expensive parts, I have rewritten these methods in C. I am calling them using ctypes which seems to work ...
TriJB's user avatar
  • 77
3 votes
1 answer
229 views

I can't figure out an easy method to include a C header with C complex types in C++. Assume you have the following files: c_source.h #include <complex.h> #ifdef __cplusplus extern "C" ...
td211's user avatar
  • 235
-2 votes
0 answers
147 views

I'm trying to make a short puzzle game that plays in the terminal, but want to use delays to make dialogue work better. The delays are happening, however they're all happening at once, and the print ...
ThisStatementIsALie's user avatar
-1 votes
0 answers
136 views

When I run cargo run, I receive the following error. I am not able to figure why rust is not detecting the badmath function. ➜ unssafe git:(master) ✗ cargo run --verbose Fresh find-msvc-tools ...
ShoebIlyas's user avatar
5 votes
1 answer
181 views

I have this C code: void print_hello(void); void far int_handler(void); void kernel(void) { // Set interruption handler in IVT *((unsigned short*)(0x30 * 4)) = (unsigned short)int_handler; ...
Alexander's user avatar
0 votes
0 answers
130 views

I am writing a code using Virtual C IDE that is to read in a text file with hundreds of lines, each containing a date, time, and eight floats; all these are assigned to arrays of according variables. ...
Solarchris's user avatar
-1 votes
1 answer
142 views

I am working on a function where I will be recieving data from an SPI communication and then get the date/month/year from them I have created a function to do the latter void set_file_header(const ...
Maaz Madha's user avatar
2 votes
5 answers
302 views

I have read about undefined behaviour for the C3 language here: https://c3-lang.org/language-rules/undefined-behaviour/ Here is the example from the page. Assume following code: uint x = foo(); uint z ...
rhall's user avatar
  • 118
4 votes
2 answers
155 views

So I have this code here #include <stdio.h> typedef union Converter { char *c; int i; } Converter; int main(int argc, char **argv) { Converter f; f.c = argv[argc - 1]; int ...
NemGamingAkos's user avatar
2 votes
1 answer
102 views

I have this Linux C project that (among others) sends (bigger than 1500 bytes) raw Ethernet frames between network interfaces of different processes. I have a bunch of system tests where this ...
Kees-Jan Hermans's user avatar
-2 votes
1 answer
160 views

I have a function which handles collision between a rectangle and a circle, the rectangle is stationary, and the circle is moving towards the rectangle at some speed. When I input lower speeds then ...
KeshawT's user avatar
  • 13
Advice
0 votes
3 replies
95 views

I developed a specifications language. Depending on the comments on this, I’ll call it a “code-aware specifications language” or a “verification-aware specifications language”. The idea I’m playing ...
Drona Nagarajan's user avatar
1 vote
0 answers
186 views

How could I get past it if the code is compiled as 64-bit? There’s no need to obtain a root shell; it’s sufficient to just verify that the address was guessed correctly. In my assignment, to bypass ...
강신호's user avatar
5 votes
1 answer
136 views

I am trying to get I²C to work on the SAMD11C14A (ATSAMD11D14A-SSUT). Just for context the MCU is soldered on a custom PCB with nothing but 4.7kΩ pull up resistors soldered to the paths and no other ...
Pascal von Flüe's user avatar
Best practices
1 vote
4 replies
129 views

I'm currently designing a library, I want this library to maintain a stable interface for old applications, However, it should be expandable. It acts as a hardware abstraction layer. The graphics ...
The19thFighter's user avatar
Advice
1 vote
11 replies
192 views

I'm parsing a file, several fscanf attempts per line Do I have to check for EOF in the returns after each one or can I do a big for-loop and check EOF in the skip-to-next-line routine? cppreference ...
NooneAtAll3's user avatar
Best practices
1 vote
1 replies
62 views

I wish to initialize a function-scoped static structure in a multi-threaded environment without using a mutex, so that the fast path (i.e. already initialized) involves little overhead. Initialization ...
Bill Webster's user avatar
4 votes
2 answers
235 views

I have the following C code that uses a static global pointer (pStruct) to implement a one-time memory allocation (a singleton pattern for an array of structs). How should I safely implement a ...
Malagus's user avatar
  • 41
1 vote
0 answers
59 views

I'm trying to create ipset through libipset from application layer. below i pasted the code for an function which tries to create an ipset with the help of libipset. but for some reason it's not ...
Vignesh's user avatar
  • 11
6 votes
1 answer
247 views

I am using Rust to target a baremetal system. My startup code is written in Assembly and is in crt0.S, it is shared between Rust, C and Assembly projects. crt0.S contains: #include "constants.h&...
Toby Jaffey's user avatar
6 votes
0 answers
137 views

I have recently learned about content related to ASLR. I referred to this article: Why aren't glibc's function addresses randomized when ASLR is enabled? However, I use the Windows 11 system ...
user24723440's user avatar

1
2 3 4 5
8167