2,709 questions
3
votes
2
answers
81
views
Can alloca() cause stack corruption in a variadic function when arguments are mismatched?
I'm using alloca() inside a variadic function to allocate stack memory dynamically based on an integer argument. However, I'm concerned about what happens if the argument is mismatched (e.g., passing ...
0
votes
1
answer
32
views
GCC converting <varargs.h> to <stdarg.h>
I'm trying to convert some very old C on AIX7.3 to use stdarg instead of varargs. The code was originally compiled with XLC, but I'm being forced to use gcc now. I'm trying to avoid the need to ...
0
votes
1
answer
61
views
What is the best way to take in optional parameters in this case? [closed]
I have a function in my library to modify the state of a given light. When the inputted mode is flashing, I want to allow the caller to pass in the interval time, on time, off time, and some other ...
-1
votes
1
answer
101
views
functional conversion with variable number of args to something plain in C++
I need to do something like this:
I have a big black box solver solver(f, ...) that takes a function (for example) as input:
double f(x, a, b, c) {
return 0.0
}
The a, b, c varies and the solver ...
3
votes
1
answer
125
views
How to call vsprintf multiple times on the same argument list?
I would like a function I can call this way:
my_printf(int unimportant,
"%-10s", "a string",
"%5.1f", 1.23,
format_string, ...
2
votes
2
answers
84
views
How can I define a vararg with three types in Java?
Since I need a Java method to receive any number of objects of three specific classes I decided to use a vararg ... to implement it. However, I have the restriction that these three classes are:
java....
1
vote
1
answer
37
views
Segmentation fault encountered at `ret void` in llvm-ir instructions
I'm currently making a compiler that outputs bare LLVM-IR instructions and implementing variadic function calls. I have defined a println function that accepts a (format) string and variable amount of ...
1
vote
1
answer
109
views
Why does this C function use of stdarg breaks when compiled by clang for Apple Silicon?
The following function MsCommand_push does not work as expected when compiled with Apple clang version 15.0.0 (clang-1500.3.9.4). It is supposed to take as input a variable number of pointer to char (...
1
vote
1
answer
86
views
Kotlin varargs to array
There is a function I want to call in a third-party library:
fun foo(strings: Array<String>)
The array strings is only used for reading, i.e. foo doesn't write to it.
Now, I want to write a ...
1
vote
2
answers
33
views
Is there way to add one more argument to the function(which has var args) with default value without breaking existing calls?
I have a function
fun foo(
id: String,
vararg values: Int,
){
...
}
and there are calls like these
fun bar1(){
foo("id_1")
foo("id_2", 1)
foo("id_3&...
1
vote
1
answer
85
views
How to skip default named arguments while setting a named variadic argument in a function call?
I have an existing method:
public function dbQuery(
string $query,
bool $flag1 = false,
int $flag2 = SOME_DEFAULT,
bool $flag3 = false
)
Now I want to adapt it so it is possible to ...
1
vote
2
answers
179
views
Why does my variadic macro throw an error when nothing is passed?
Context
I'm trying to create a C program that takes multiple integers as input via the print(...) macro, without needing to pass the length of arguments manually from the main function. To achieve ...
2
votes
2
answers
191
views
How to create nested variadic functions?
I can't and won't bore you with the details, but my system has these specific requirements:
Actions must be called and registered at runtime.
Each Action can have multiple targets, and these targets ...
-1
votes
1
answer
99
views
How to deal with multiple types on var_arg in c++? [closed]
How to do that?
The code is causing: null pointer dereference.
10-08 17:26:00.835 5249 5617 D DigestGenerator: /apex/com.android.runtime/lib/bionic/libc.so!libc.so (strstr+) ()
10-08 17:26:00.835 ...
0
votes
2
answers
74
views
Passing a variadic function to a variadic function via a pointer
I'm kinda confused with the usage of <stdarg.h> features. I can't figure out how to properly pass a va_list to the argument function. Here's a simplified example of what I'm trying to achive:
#...