Skip to main content
4 votes
2 answers
140 views

I have a program that I would like to build in Visual Studio 2026, but struggle with the errors appearing. One simplified piece of code is as follows: void f(const void*) {} int main() { ...
Fedor's user avatar
  • 25.4k
Advice
1 vote
9 replies
83 views

I read online that casting void* to any function pointer produces undefined behaviour in C. I printed the sizeof(void*) and sizeof(&some_func) and both are 8 bytes. Given that both types have the ...
Daniel Muñoz's user avatar
Advice
0 votes
14 replies
6k views

The following code is accepted by GCC and the resulting binary prints the expected results. But is it standard conform and would always work on different systems using different compilers? Minimal ...
Martin Fehrs's user avatar
  • 1,195
1 vote
2 answers
184 views

I've created the function void add_entry(char key[], void* value, char file[], ValueType type) and I want to use my generic function to get the typeof the pointer #define typeof(x) _Generic((x), \ ...
user31846615's user avatar
3 votes
1 answer
89 views

Suppose I create a shared memory object: from multiprocessing import shared_memory shm_a = shared_memory.SharedMemory(create=True, size=1024) buffer = shm_a.buf and put a generic object of a generic ...
Geremia's user avatar
  • 5,856
1 vote
1 answer
79 views

I have an array of pointers to structs in C as typedef struct{ int elem1; char *elem2; ... }example_t; example_t *array[MAX_SIZE]; I did generic functions for add or delete pointers to ...
Daniel Muñoz's user avatar
4 votes
1 answer
203 views

I am currently trying to make a code more safe for a cybersecurity exercise. I was asked to make the flag contained in the secret_function() come out. The problem is that I can't modify the code and ...
Tempest_Sword's user avatar
3 votes
2 answers
130 views

I have written this example to try and explain the problem. I have defined a function as follows: // Return name from given user. typedef char *(name)(void *user); And then implemented this function ...
sja785's user avatar
  • 31
1 vote
1 answer
139 views

Context I've been trying to learn C and have become a little more comfortable in it recently. I am building a 2d space shooting game (kind of Galaga inspired, written using SDL) and decided to use ...
Luke Fisher's user avatar
0 votes
1 answer
55 views

I am trying to allocate memory for certain data structures (array, matrix, custom_array, ...). The problem I think I am facing is that I am not able to cast the proper types to the passed pointers ...
Megrah Yacine's user avatar
0 votes
2 answers
129 views

I'm trying to work my way through The C Programming Language, 2nd Edition, and I can't get my head around exactly what is happening in the following code. The example from the book works just fine ...
Mike T.'s user avatar
  • 417
1 vote
1 answer
525 views

I have some legacy code that reads like this: bool has_attribute(int kvidx) const { void* v = nullptr; int flag = 0; MPI_Comm_get_attr(impl_, kvidx, &v, &flag); return flag != ...
alfC's user avatar
  • 16.8k
0 votes
5 answers
245 views

I'm a C beginner, and I've got a question while I read the Chapter 19.5 of C Programming: A Modern Approach (2nd Edition) by K. N. King. In this chapter, the author explains what is program design and ...
Doohyeon Won's user avatar
2 votes
3 answers
181 views

Setup I'm taking over code from another person. I found a coding pattern that seems odd to me. This is for an embedded 32 bit PIC processor, in case that's relevant. They have a custom typedef in a ...
Trashman's user avatar
  • 1,714
0 votes
0 answers
34 views

I'm attempting to write a program that takes data from main (member type structure), then passes it to (void *) within the function, placing it on the stack in a linked list. In order to use this ...
Ratdude's user avatar
  • 93

15 30 50 per page
1
2 3 4 5
94