Category "c"

Intermittent SIGBUS on shared memory segment

I have a server process that allocates a big chunk of memory using the System V XSI shared memory calls (shmget/shmat), from address to 0x500000000 to 0x1d00000

Why not possible to fill any integer straight to a pointer variable?

#include <stdio.h> int main(void) { int* ptr = NULL; *ptr = 10; printf("%d", *ptr); return 0; } I am very new to C programming and sorry

Does i = x[i]++; lead to undefined behavior?

Can someone please explain whether i = x[i]++; lead to undefined behavior? Note: x[i] and i are not both volatile and x[i] does not overlap i. There is C11, 6.5

Is it possible to set bits of a void* value without type casting it to an int or char?

I am working on a project that requires me to allocate some space using the mmap function and I need to create a bitmap in the beginning of the allocated space.

What to use on Nodejs addons. Node.h or Napi.h

I have some pretty simple questions. What is the main difference between node.h and napi.h. What should I use for normal/personal use case. Why are there more "

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