Skip to main content
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 ...
Alphin Thomas's user avatar
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 ...
Derek Hill's user avatar
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 ...
Torben Conto's user avatar
-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 ...
Tony Shi's user avatar
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, ...
Mark Dominus's user avatar
  • 1,808
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....
Joe DiNottra's user avatar
  • 1,027
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 ...
johron's user avatar
  • 13
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 (...
dde's user avatar
  • 192
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 ...
k314159's user avatar
  • 11.5k
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&...
gstackoverflow's user avatar
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 ...
Alex Dawn's user avatar
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 ...
Sakib Khandaker's user avatar
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 ...
fiqcerzvgm's user avatar
-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 ...
vdTOG's user avatar
  • 21
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: #...
yurich's user avatar
  • 175

15 30 50 per page
1
2 3 4 5
181