variadic-functions Questions
3
Solved
I've this code that plays with variadic functions:
#include <cstdarg>
#include <iostream>
template <typename T>
void bar(va_list vl) {
std::cout << va_arg(vl, T) <<...
Arni asked 3/2, 2020 at 14:37
6
Solved
If I have a va_list I know how to extract all its elements:
void printInts(int n,...)
{
va_list va;
va_start(va, n);
for(unsigned int i=0; i<n; i++)
{
int arg=va_arg(va, int);
printf("%d...
Fife asked 4/12, 2012 at 13:11
8
Solved
I have a method
public boolean findANDsetText (String Description, String ... extra ) {
inside I want to call another method and pass it extras but I want to add new element (Description) to ex...
Leakey asked 4/7, 2012 at 2:46
4
Solved
Maybe this will be obviously simple for most of you, but could you please give an example how to create similar methods (in Objective-C) and functions in C to create functions like NSString's strin...
Gonococcus asked 26/1, 2011 at 12:41
12
Solved
So I have 2 functions that both have similar arguments
void example(int a, int b, ...);
void exampleB(int b, ...);
Now example calls exampleB, but how can I pass along the variables in the varia...
Berry asked 20/8, 2010 at 12:22
8
Solved
In The Swift Programming Language, it says:
Functions can also take a variable number of arguments, collecting them into an array.
func sumOf(numbers: Int...) -> Int {
...
}
When I cal...
Cohesion asked 3/6, 2014 at 20:29
5
Solved
I'm implementing an API an have a method which you pass a list of paths where the program reads resources from
public void importFrom(String... paths) {
}
I'm using varargs to make calling the ...
Wordplay asked 31/10, 2011 at 8:31
8
Solved
I am looking to do this in C/C++. I came across Variable Length Arguments, but this suggests a solution with Python and C using libffi.
Now, if I want to wrap the printf function with myprintf.
I d...
Nihi asked 3/9, 2008 at 10:12
3
Solved
In PostgreSQL 9.3.4 release note it says:
Ensure that the planner sees equivalent VARIADIC and non-VARIADIC function calls as equivalent (Tom Lane)
I searched the PostgreSQL manual and couldn't f...
Pantsuit asked 19/11, 2015 at 11:25
6
Solved
I read here that in C void foo() means a function foo taking an unspecified number of arguments of unspecified type.
Can anyone give me or point me to an example where a C function takes an unspeci...
Chug asked 27/2, 2014 at 16:4
10
Solved
I'm trying to combine the slice [1, 2] and the slice [3, 4]. How can I do this in Go?
I tried:
append([]int{1,2}, []int{3,4})
but got:
cannot use []int literal (type []int) as type int in appe...
Gordie asked 27/4, 2013 at 4:8
6
Solved
I'm trying to sort any array with array_multisort() and everything is working great. However, based on conditions in my script, I need to change the options.
What I have so far is this:
array_multi...
Odalisque asked 19/3, 2010 at 2:55
7
Solved
For example, you might have function with a complicated signature and varargs:
fun complicated(easy: Boolean = false, hard: Boolean = true, vararg numbers: Int)
It would make sense that you shou...
Indestructible asked 14/8, 2016 at 9:54
11
Solved
I have a PHP function that takes a variable number of arguments (using func_num_args() and func_get_args()), but the number of arguments I want to pass the function depends on the length of an arra...
Marilumarilyn asked 14/9, 2009 at 16:37
13
Solved
I've been trying to get to mock a method with vararg parameters using Mockito:
interface A {
B b(int x, int y, C... c);
}
A a = mock(A.class);
B b = mock(B.class);
when(a.b(anyInt(), anyInt(), ...
Cerulean asked 13/4, 2010 at 17:8
28
Solved
What do *args and **kwargs mean in these function definitions?
def foo(x, y, *args):
pass
def bar(x, y, **kwargs):
pass
See What do ** (double star/asterisk) and * (star/asterisk) mean in a fu...
Policewoman asked 31/8, 2008 at 15:4
1
Upon code review/clang-tidy runs, I came across a function with a signature like this:
void appendFoo(const char * fmt, va_list& rVaList);
I have never seen this before.
Afaik, you can pass va...
Donkey asked 13/2, 2023 at 14:1
2
All versions of varargs.h and/or stdarg.h I've seen either define va_end as an empty macro or some opaque compiler-specific function that I guess doesn't do anything either. The rationale in the C ...
Bikales asked 10/8, 2021 at 16:25
2
Solved
I've created a struct, that groups the format character and a pointer to the function which prints according to the formatter.
typedef struct formatter
{
char spec;
void (*print)(va_list);
} fmt;...
Underact asked 25/6, 2023 at 17:27
3
/* Debugging */
#ifdef DEBUG_THRU_UART0
# define DEBUG(...) printString (__VA_ARGS__)
#else
void dummyFunc(void);
# define DEBUG(...) dummyFunc()
#endif
I've seen this notation in different head...
Footworn asked 26/9, 2014 at 7:10
6
Solved
I'd like to be able to create a function like:
class A {
private String extraVar;
public String myFormat(String format, Object ... args){
return String.format(format, extraVar, args);
}
}
Th...
Lurleen asked 27/5, 2010 at 21:36
5
Solved
void TestPrint(char* format, ...)
{
va_list argList;
va_start(argList, format);
printf(format, argList);
va_end(argList);
}
int main()
{
TestPrint("Test print %s %d\n", "string", 55);
retu...
Thrombo asked 12/5, 2011 at 11:34
0
This post is not just about unresolved linker symbols in general, but about a variadic function in a class with a Q_OBJECT macro. The macro creates a lot of components automatically generated...
Quadratics asked 23/4, 2023 at 3:28
0
If I compile g++ with -Wformat on the following code, I get a warning, as expected.
int main(int argc, char * argv[])
{
printf("argc %lld\n", argc);
}
However, if compile the following ...
Spermic asked 25/2, 2023 at 14:21
5
Solved
I am trying to write a variadic template for finding the maximum of an arbitrary amount of numbers (this is just for practicing variadic templates).
However, I have sort of hit a wall and can't un...
Prentice asked 14/1, 2012 at 4:24
1 Next >
© 2022 - 2024 — McMap. All rights reserved.