Category "c"

How gcc decide to use dynamics library when creating executable?

I am creating an executable with this: gcc elliptical.o -Llibs -lhfcal -o elliptical In my libs sub folder there are: libhfcal.a libhfcal.so files. My purpos

simple code to read jpg files read retured 0 errno 0

I have simple code that reads a .jpg file But my read returns 0 and errno is 0. I just prefer of use read with read syscall. #include <stdio.h> #include &

reading Memory-Mapped IO registers How to (from datasheet) and using them in mmap

I have intel system with Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (Lewisville) (rev 04). I have downloaded the datasheet like d

GCC, constant tables and .rodata

I have a strange problem with gcc and constants and .rodata Let's assume: typedef const struct { const char *a; } data_t; typedef const struct { const dat

Having Issues with Segmentation Error in Doubly Linked List Implementation

I'm pretty new to C and I can't figure out why I'm getting a segmentation fault from this code: void delete_list(LIST *list) { NODE* n = list->head; whil

Array too small for DCT transformation in LabWindows CVI

I have been doing a school project about digital watermark based on DCT using LabWindows CVI 2012. I divide an image with the size of 512 * 512 into many 8 * 8

Array too small for DCT transformation in LabWindows CVI

I have been doing a school project about digital watermark based on DCT using LabWindows CVI 2012. I divide an image with the size of 512 * 512 into many 8 * 8

Invalid Initializer When I try to call function from another function

I have two functions. One that returns the part of the string for me. Don't ask me why I'm doing it inside a function because I want to run this inside a thread

LuaJIT and GCC: number of cores

BACKGROUND: I read several articles about performance benchmarks between LuaJIT and C-language. There were different conclusions, so I tried to compare the spee

Python in C DLL

I just created a DLL in C with Python in it. When I export my function with python functions in it, I can't call it in my Python code But when I export a classi

user pointer in g_signal_connect is not passed correctly

I have a gtk scale with range, and my goal is to capture when the user releases the click from the scale. (value-changed is called even when the slider is still

C, Do structs with multiple dynamically allocated arrays need to be resized for every allocation?

Below I have a struct with multiple dynamically allocated char arrays. It compiles, Valgrind indicates no issues and it functions as anticipated. Earlier, someo

Determining the validity of a multi-hot encoding using bit manipulation

Suppose I have N items and a binary number that represents inclusion of these items in a result: N = 4 # items 1 and 3 will be included in the result vector =

C auto variable isn't freed after function return

I have the following C code: #include <stdio.h> #include <stdlib.h> typedef struct num { int a; struct num *c; } num; void init_struct(num *n)

Why is calling snprintf() so slow?

Our internal program is written in C and makes extensive use of snprintf() for many pieces, and I noticed that during debugging with perf record/report, it's sp

Does adding a star after a pointer struct definition make it a double pointer?

I have a struct typedef struct hash_entry_{ char *string; void *data; struct hash_entry *next; }hash_entry, *p_entry; I am referencing p_entry later i

Break down the logic for a C for-loop into something I can implement in MIPS? (count number occurrences in an array)

Hi all i am converting my C code to MIPS but problem is here i couldn't make correct logic for this for (int i=0;i<count;i++) { h[a[i]]++; } as

Is it possible to use Visual Studio 2022 Test Explorer to run C unit test?

I would like to run ansi C unit tests in VS by mean of Test Explorer (not only with Console). I saw that it's possible for C++ projects (https://docs.microsoft.

How to append to a zlib stream?

I have been trying to append raw bytes to an existing zlib stream using the deflatePrime function provided by the zlib library. However, i cannot understand wha

Is there a way to use the #define directive to create a constant struct?

Let's say I have this struct typedef struct { int AM; char* name, surname; }Item; and I want to define a constant NULLitem with AM = -1 and NULL name/