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

I've found that there are conditions that the second argument of va_start(ap, last) must satisfy, which are: last must not be a register variable last must not be a function last must not be an array ...
Doohyeon Won's user avatar
-4 votes
1 answer
82 views

I'm experimenting a bit with trying to build NodeJS 24.11.1 with GCC 13.4.0 on an older OS X system, mostly as a can-it-be-done project. Regardless of the reasons, among the hurdles that could be ...
RJVB's user avatar
  • 820
Best practices
0 votes
15 replies
196 views

man stdarg shows, under the va_args macro description: If ap is passed to a function that uses va_arg(ap,type), then the value of ap is undefined after the return of that function. If we look at ...
m0d1nst4ll3r's user avatar
1 vote
1 answer
36 views

I couldn't find exactly my scenario in other questions, please redirect me if you see fit but: I have a function with args with variable length, which i check inside and take different actions based ...
meerkatUI's user avatar
15 votes
3 answers
2k views

I have a very simple C program where I am printing variables of different sizes. #include <stdio.h> unsigned int long long a; unsigned int c; int main() { a = 0x1111111122222222; c = ...
Krishna's user avatar
  • 1,632
3 votes
3 answers
467 views

Here is the variadic example: https://en.cppreference.com/w/c/variadic.html I want to define two functions but I don't know how to do it correctly. The "foo" function should accept "...
stackbiz's user avatar
  • 1,914
10 votes
2 answers
123 views

I was going through the System V AMD64 ABI and couldn’t find a clear explanation for why the AL field (which tracks how many floating-point registers are used) is necessary. From my understanding, ...
OODAX's user avatar
  • 159
0 votes
1 answer
248 views

I have a C function that uses va_list but needs to skip the first two arguments in here: static size_t event_type_CURSOR_POS__weight( const void * self, va_list * app ) { (void) va_arg( *app, ...
Sam's user avatar
  • 119
1 vote
4 answers
214 views

Due to templates being templates, they need to be defined in a header file (making explicit instantiations is not an option). I have an extern function which takes an expanded template parameter pack: ...
 sentientbottleofwine's user avatar
2 votes
1 answer
170 views

I am just wondering why the following code by using va_start, the addresses of the stack parameters are not in order anymore. va_start is a gcc builtin. But how can it change the addresses of the ...
user14825657's user avatar
1 vote
2 answers
142 views

So I was trying to come up with a way to split a given parameter pack args... into two separate packs args1... and args2... (at some specified index, 3 in this case). I also wanted to minimize the ...
Orbit's user avatar
  • 23
3 votes
3 answers
262 views

I know that we can do more arguments than placeholders when using printf, in which case, the excessive arguments are simply ignored: printf("%s", "Hello friend!\n", "Long time ...
PkDrew's user avatar
  • 2,301
3 votes
0 answers
99 views

Assume there is a base class in a Java library which cannot be modified public class BaseClass { public Something function(int... args){ ... } } Typically, this would be overridden in Scala by ...
Ian Bertolacci's user avatar
4 votes
1 answer
161 views

TL;DR: is C23's universal initialization type var = {}; safe for all types, including standard opaque ones, such as va_list? I have code that uses variable arguments. An older version of a static ...
Grigory Rechistov's user avatar
1 vote
1 answer
65 views

I'm curently exploring Lua (5.4.7) vm implementation, it's relatively simple but i can't figure our how return works in case of vararg functions. functions with fixed amount of params are quite simple,...
vanilla's user avatar
  • 145
3 votes
2 answers
138 views

Does any of the C Standards describe any kind of a check to ensure that const is used and accessed appropriately with variable argument lists? If I have the following source for a function with a ...
Richard Chambers's user avatar
3 votes
2 answers
121 views

I was doing a CTF reversing challenge when I came across this C code in Ghidra: int main(void) { int iVar1; char input[32]; fwrite("Password: ",1,10,stdout); __isoc99_scanf("...
1zverg's user avatar
  • 875
1 vote
1 answer
80 views

I'm generating classes with ByteBuddy. In one place, I need to call a static utility method which accepts varargs of type String. My code looks like this: String[] myStringArray = generateParameters() ...
Martin Häusler's user avatar
2 votes
2 answers
218 views

Going through a code review and found named argument call being used to a argument that uses the spread operator for variable args (vargs). To my suprise it works fine for 1 argument, but I cannot ...
Alex Dawn's user avatar
3 votes
2 answers
97 views

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
72 views

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
64 views

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
110 views

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
155 views

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,839
2 votes
2 answers
104 views

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,083
1 vote
1 answer
55 views

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
125 views

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
  • 212
1 vote
1 answer
113 views

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
  • 12.4k
1 vote
2 answers
39 views

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
2 answers
205 views

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
232 views

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
221 views

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
107 views

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
103 views

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
  • 157
0 votes
1 answer
77 views

fcntl is defined as a vararg function int fcntl(int fd, int action, ...) which sometimes takes an int arg and sometimes void* arg. I'd like to write a logging interceptor for this libc function (using ...
Vadim Kantorov's user avatar
0 votes
0 answers
51 views

I have a generic class: class A[T]: pass And a function that extracts T from A: def func[T](arg: A[T]) -> T: pass Now my function can accept *args and extract all Ts from all of the given As. ...
Bharel's user avatar
  • 27.5k
0 votes
2 answers
433 views

Recently I had a situation where it was logical to use varargs in java. I then found out that varargs are just syntactic sugar for arrays, and was curious about the performance repercussions that ...
iexav's user avatar
  • 121
1 vote
2 answers
148 views

When designing a (performant) method with variable parameter length like <T> void consume(T t1) <T> void consume(T t1, T t2) <T> void consume(T t1, T t2, T t3) and a) another ...
bjmi's user avatar
  • 615
1 vote
1 answer
125 views

I want to annotate a function that combines several iterators or generators into one, the case for two iterators is trivial: def merge_two_iterators[T, H]( gen1: Iterator[T], gen2: Iterator[H] ...
Ziur Olpa's user avatar
  • 2,235
1 vote
1 answer
204 views

I'm currently working on a Swift project and encountered an issue when trying to pass a variadic parameter from one function to another. Specifically, I expected that I could directly pass the ...
markb's user avatar
  • 1,381
0 votes
3 answers
89 views

For example I have C# method like this: void someMethod(String arg1, params object[] extras) { foreach (object extra in extras) { Console.WriteLine(extra); } } When I call it like ...
Dmitry's user avatar
  • 423
0 votes
1 answer
111 views

Here is a basic version that demonstrates the issue. Does anyone know why I cannot pass the return value to the wrapped function? The javascript works but typescript is not allowing it. // accept a ...
Jose Castellanos's user avatar
1 vote
1 answer
80 views

I have the following function for Logging purposes: void LogE(const char* scope, const char* s, ...) { fprintf(stderr, "%s : ", scope); va_list list; va_start(list, s); ...
Raildex's user avatar
  • 5,428
0 votes
1 answer
80 views

In typed Python, how do you type a *args list that you're expecting to pass to another argument that is a higher kinded function? For example, this function takes a function and its first argument and ...
Mike Samuel's user avatar
1 vote
3 answers
198 views

I tried to do function that checks if the argument matches specific values. I think know how to do it with recursion or std::initializer_list, but I want to do it with fold. Here is non working code: ...
Nick's user avatar
  • 10.6k
0 votes
1 answer
601 views

I am trying to call a particular member function in all elements of a tuple using std::apply. This works when I use a lambda but not when defining a free function. Following Template tuple - calling a ...
das_blob's user avatar
4 votes
1 answer
237 views

I did some test code to demonstrate different output on Windows and Linux #include <stdarg.h> #include <stdio.h> void print_vint(va_list args) { int i = va_arg(args, int); printf(&...
zdenko.s's user avatar
  • 1,112
-2 votes
1 answer
190 views

By definition, in stdarg.h typedef char* va_list.so the size of va_list should be 8 not 24 in ubuntu 20.04 64bits gcc 9.4.0, i don't know why i get the size of va_list is 24? I runed the following ...
Vicent's user avatar
  • 1
0 votes
2 answers
103 views

I have objects that are currently initialized via one-parameter init functions that take an Array or Dictionary. I've realized that I can use ExpressibleByArrayLiteral and ...
pkamb's user avatar
  • 35.5k
1 vote
0 answers
43 views

I have read the following about passing arguments to variadic functions, https://stackoverflow.com/a/3530807/22299201 #include<stdio.h> #include<string.h> #include<stdarg.h> #define ...
xihare's user avatar
  • 39

1
2 3 4 5
55