Category "c"

clang linker error when compiling simple C program on OS X

I was building this code from this article I was using the recommended command to build it: gcc -Wall -o keyboard_leds keyboard_leds.c -framework IOKit -framewo

Does Unary + operator do type conversions?

Till now I was believing that there is no use of unary + operator. But then I came across with following example: char ch; short sh; int i; printf("%d %d %d",s

Best approach to mock hiredis library in C

I am writing a project that takes advantage of the hiredis redis client library. What is the best approach to mock this library for use in writing tests? For

Unable to compile XINU source code after adding a new function in assembly language

I have added a file function.S in sys folder in XINU. .text .globl zfunction zfunction: <x86 code> equivalent C code for this function is long

Can sizeof(size_t) be less than sizeof(int)?

Can sizeof(size_t) be less than sizeof(int)? Do the C and/or C++ standards guarantee that using unsigned int for array indexing is always safe?

Why is printf round floating point numbers up?

I am trying to print some floating point numbers using printf. For example: int main() { printf("%.1f",76.75); return 0; } Output: 76.8 And I have som

How to create UDP socket connection to receive data from gstreamer udpsink?

I want to create a UDP socket connection to receive data from GStreamer udpsink. When I create a Gstreamer pipeline using udpsink, VLC can play the stream. I wa

GtkStatusIcon label in Gnome3

How can affect on my app's status icon label in Gnome3? When i moving cursor on it shows me my app's executable name. How can I change it?

Idiomatic way to check for non-zero

When I wish to check if a value is 0 in C, how is it idiomatically done? if (!num) if (num == 0)

Define data type of enum in C for memory

I could not find a direct answer to this but is it possible to force a certain kind of data type for an enum in C ? e.g I have an enum for a state machine that

building kernel module and resolve missing symbol definitions

If I build a module which depends on other modules, and i get this warning: 'function or symbol ?' [source dir/my_module.ko] undefined! What does the warn

Check whether a path is absolute or relative

How do you check whether a path is absolute or relative, using C on Linux?

C - forward declaration of enums?

Forward declaration of enums in C does not work for me. I searched the internet and Stack Overflow but all of the questions regarding forward declarations of en

Why does the indexing start with zero in 'C'?

Why does the indexing in an array start with zero in C and not with 1?

How to run a c program in ubuntu 12.04

Hello i am new to ubuntu. I want to run a c program in ubuntu.On the terminal i typed "make ex1.c" (my file name is ex1) and the after pressing enter button , t

What does reaping children imply?

I have just had a lecture that sums reaping as: Reaping Performed by parent on terminated child (using wait or waitpid) Parent is given exit status informato

kernel make error "arch/x86/entry/syscall_64.o:(.rodata+0x1120): undefined reference to"

This error stops my kernel make process ld: arch/x86/entry/syscall_64.o:(.rodata+0x1120): undefined reference to `__x64_sys_fd' BTF .btf.vmlinux.bin.o pahol

How to implement google mock to mock the C fopen function

I am writing a unit test for embedded C codes using google test/mock. The C function code looks like this. int readGPIOSysfs(int ioport){ ... FILE *f = fop

Sleeping barber using semaphore

I am having a problem in the synchronisation of threads. I m trying to implement sleeping barber problem in a different approach. When i run the code the thread

two pass assembler fix

I'm working on a 2 pass assembler and have been looking at sample codes online to familiarise myself. I found the following code but there appears to be a probl