Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
57 views

Suppose I have a function like this. How can I get a reference to that function and then call it? function Hello($name) { Write-Output "Hello, $name" }
dan-gph's user avatar
  • 17.1k
1 vote
1 answer
127 views

I have legacy code which uses typedef for function pointers (and yes, void* as well). I reduced it to this: #include <memory> #include <functional> typedef void (*funx_t)(const double *, ...
Thomas Weller's user avatar
4 votes
1 answer
165 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
30 votes
6 answers
5k views

From K&R page 99: As formal parameters in a function definition, char s[]; and char *s; are equivalent; we prefer the latter because it says more explicitly that the variable is a pointer. I ...
Roee Zamir's user avatar
1 vote
3 answers
178 views

Let's say I want to store a collection of function pointers (from lambdas), where each functions body is very similar. Writing everything out by hand gets repetitive and hard to manage, so instead I ...
Joel's user avatar
  • 1,777
2 votes
1 answer
91 views

#include <stdio.h> typedef int (*func_t)(int); int foo(int x) { return x * 2; } int main() { const func_t ptr = foo; // Works //const func_t *ptr = &foo; // Fails: why? ...
Alphin Thomas's user avatar
2 votes
2 answers
64 views

I am currently working on a c++ project leveraging the features of Postgis. Postgis provides handles to use custom memory allocators for the memory management. The allocator should be of the signature:...
Jennifer Nissitta's user avatar
2 votes
1 answer
106 views

I had an interrupt functionality implementation in my embedded project with global variables. The interrupt checks PWM signal duty cycle and sets the value of a bool var to true if the value is ...
marus's user avatar
  • 23
0 votes
1 answer
106 views

#include <stdio.h> #include <stdlib.h> typedef struct node* Node; struct node{ int a; struct node* next; }; void insertAtBeginning(Node head){ Node temp = malloc(sizeof(struct node)); ...
Thirumal R's user avatar
1 vote
1 answer
63 views

I'm trying to capture when a child executes an abort. The following is a MCVE that should give an idea of what I'm trying to do. #include <iostream> #include <cstdio> #include <iomanip&...
SailorCire's user avatar
1 vote
2 answers
71 views

Ive been trying to set the values of matrices with the help of methods that take pointers, But I am unable to do this. The setMatrixValue method stops working when the loop reaches the second row. The ...
carbonatedWaterr's user avatar
3 votes
1 answer
97 views

This is a niche question, but I'm struggling to find a sufficient answer. Struct members can be const, but can a function pointer/reference member be declared const? Based off my reading of C++17 ...
JWCS's user avatar
  • 1,223
1 vote
0 answers
104 views

I have a scheduler class template that I'd like to use with one of several timer classes. I'd like to use a concept to verify a given timer class has what the scheduler needs. // One of several that ...
mthiffau's user avatar
  • 133
2 votes
4 answers
208 views

EDIT2: It seems that the standard is not exactly clear, and appears to at least partially contradict itself in different parts on the usage of void* or struct* when casting function pointers. The lack ...
Oliver Schönrock'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
1 vote
2 answers
150 views

I want to declare a function while setting the value of a function pointer. A TypeScript equivalent: let fp: () => void; fp = () => { console.log("Hello from inline function declaration!&...
CrossScar's user avatar
1 vote
0 answers
55 views

I have to implement a low-level interface for the library which exposes structure with a function pointers like this: struct Interface { int (*IterfaceFn) (int value); }; Library then expects a ...
sokzmalin's user avatar
0 votes
5 answers
238 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
4 answers
175 views

I am trying to use a function pointer inside a struct, whereas the function pointer needs an instance of the struct itself as argument. My current code snippet looks like this: #include "stdio.h&...
sim12's user avatar
  • 23
0 votes
1 answer
240 views

Note: In case the post seems long, one can directly jump to the section starting with "I was wondering.." at the end, in case one wants to skip the buildup/context. Buildup/Context: For the ...
Abhishek Ghosh's user avatar
3 votes
1 answer
307 views

I have some C code which builds OK with gcc-11 and earlier but not gcc-12 and later. This illustrates the problem (this isn't the actual code I'm working on): #include <stdint.h> #include <...
gebjon's user avatar
  • 131
0 votes
1 answer
125 views

Here is the minimal reproducible example: // my_func.h typedef volatile struct { int a; } my_vdata_t; typedef struct { int a; } my_data_t; extern void (*vfunc)(my_vdata_t* data); extern void (*...
Simpdanny's user avatar
1 vote
2 answers
100 views

I have a class: #include "pico/stdlib.h" #include "hardware/gpio.h" class ButtonsController { public: ButtonsController(){}; void UpdateButtons(bool first_enable, bool ...
Dominik's user avatar
  • 35
-3 votes
2 answers
140 views

I got a snippet of C code from online, and I am trying to compile it. I am getting the following error. error: expected declaration specifiers or '...' before ')' token 6 | extern FUNC(void, ...
user2986042's user avatar
  • 1,300
-4 votes
4 answers
376 views

In C language there are 2 ways to pass arguments to functions, right? One of them is Pass by address. Do you not need to always pass a pointer? I haven't tried anything yet just wanted to know its ...
Zel's user avatar
  • 11

1
2 3 4 5
90