Thread View: pl.comp.lang.c
1 messages
1 total messages
Started by Borneq
Tue, 19 Sep 2017 10:51
Wołanie variadic z variadic z inną liczbą stałych parametrów
Author: Borneq
Date: Tue, 19 Sep 2017 10:51
Date: Tue, 19 Sep 2017 10:51
28 lines
1980 bytes
1980 bytes
Gdy mamy taką samą stałą liczbę parametrów:
https://stackoverflow.com/questions/16447951/how-to-forward-variable-number-of-arguments-to-another-function
Ale ja mam:
void vrequest(string fmt, va_list &ap);
void request(string fmt, ...);
funkcje ogólne:
Funkcja konkretna:
void HBaseClient::testVar(uint8_t alone, uint8_t numVar, ...) {
va_list argptr;
va_start(argptr, numVar);
//vrequest("i8i8v8i16s8", testVAR, alone, numGroup, argptr);<--HERE
va_end(argptr);
RetObj ro;
response(ro);
if (ro.type != RetObjEnum::void_t) throw Exception("bad return
testVar");
}
Ma pewną stała liczbę parametrów jak "alone", parametr "numVar"
określający ilość parametrów zmiennych i parametry zmienne.
do vrequest przesyłam znaczniki w postaci tekstowej, identyfikator
testVAR, parametry stałe jak "alone" i "numVar" a dopiero potem
parametry zmienne
Na stackoverflow.com było proste przesyłanie va_list, tu potrzebna
manipulacja - stworzenie drugiej listy składającej się ze stałych i z
listy argptr.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads