Skip to main content
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
14 votes
3 answers
2k views

Why does a mismatching printf specifier also affect subsequent arguments?

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,612
3 votes
3 answers
426 views

How to define variadic **argv in C function

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,766
10 votes
2 answers
112 views

Why is the AL field (FP register usage count) necessary in the SysV ABI?

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

Is it safe to use `(void) va_arg(...)` to advance the `va_list` in C? [closed]

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

Is it possible to somehow contain an extern "C" function within a header file?

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

variable number of arguments with -fstack-protector-strong

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
1 answer
115 views

Trying to split parameter pack into two smaller packs using an index sequence and nested lambdas leads to weird compiler behaviors

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
4 votes
3 answers
249 views

More placeholders than arguments for 'printf'

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,659
3 votes
0 answers
97 views

How to override a varargs java method in a scala class which is still callable in both scala and java variadically?

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

Is it legal to empty-initialize `va_list` with `{}` in C23 before calling `va_start()`?

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

Lua stack and vararg functions

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

calling function with variable argument list using const arguments

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

Why does scanf() read only after specified text?

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

How to call varargs method in ByteBuddy in a way that bakes the arguments array as constants into the bytecode?

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

Is there a way to use both named args and variable args in a function call?

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

15 30 50 per page
1
2 3 4 5
182
Morty Proxy This is a proxified and sanitized view of the page, visit original site.