ok if someone want regular c stuff
(there still are some parts of c i dont learned (i got no tiem as they
vere rarely used)it is this variadic stuff
i once seen it like maybe outdated/obsolete/archaic stuff but in fact
i had probably normie mind in this point - becouse later i discovered
that this printf is not such bad in practice (im not sure if i would
name it very good but if back then i got a view that my apps shouldnt
use it and maybe i should use my own separate routines for printing text
and numbers it showed to be more annoying (those print("ss");
printN(23);-a print("aassaaas"); ) than printf
but im not fully comprehending this varargs stuff and i think i should
learn it (though its panful for old 50 year old man)
so the question is the passing down the variadic arguments costly?
how it work?
i mean when-a you got function that takes varargs like
-avoid slog_yellow(char *format, ...)
-a{
-a-a-a SlogColor(0xffff00);-a-a-a va_list args; va_start(args, format); slog(format, args);-a-a-a va_end(args);
-a}
and you pass it down to oryginal slog() which also takes varargs
void slog_(char *format, ...)
-a{
-a-a-a-a-a va_list args;
-a-a-a-a-a va_start(args, format);
-a-a-a-a int n =-a vsnprintf(&slog_[slog_top][0], slog_line_max, format, args);
-a-a-a-a-a va_end(args);
-a-a-a-aslog_top++;
}
which in turn as uit shows passes it down to vsnprintf
does this passing is costly?
as i dont understand this well in fact i may make some errors codng it
(but as i said up the point i was not much fiery reasons to learn this)
ok if someone want regular c stuff
(there still are some parts of c i dont learned (i got no tiem as they
vere rarely used)it is this variadic stuff
i once seen it like maybe outdated/obsolete/archaic stuff but in fact
i had probably normie mind in this point - becouse later i discovered
that this printf is not such bad in practice (im not sure if i would
name it very good but if back then i got a view that my apps shouldnt
use it and maybe i should use my own separate routines for printing text
and numbers it showed to be more annoying (those print("ss");
printN(23);-a print("aassaaas"); ) than printf
but im not fully comprehending this varargs stuff and i think i should
learn it (though its panful for old 50 year old man)
so the question is the passing down the variadic arguments costly?
how it work?
i mean when-a you got function that takes varargs like
-avoid slog_yellow(char *format, ...)
-a{
-a-a-a SlogColor(0xffff00);-a-a-a va_list args; va_start(args, format); slog(format, args);-a-a-a va_end(args);
-a}
and you pass it down to oryginal slog() which also takes varargs
void slog_(char *format, ...)
-a{
-a-a-a-a-a va_list args;
-a-a-a-a-a va_start(args, format);
-a-a-a-a int n =-a vsnprintf(&slog_[slog_top][0], slog_line_max, format, args);
-a-a-a-a-a va_end(args);
-a-a-a-aslog_top++;
}
which in turn as uit shows passes it down to vsnprintf
does this passing is costly?
On 11/09/2026 12:25, fir wrote:
ok if someone want regular c stuff
(there still are some parts of c i dont learned (i got no tiem as they
vere rarely used)it is this variadic stuff
i once seen it like maybe outdated/obsolete/archaic stuff but in fact
i had probably normie mind in this point - becouse later i discovered
that this printf is not such bad in practice (im not sure if i would
name it very good but if back then i got a view that my apps shouldnt
use it and maybe i should use my own separate routines for printing
text and numbers it showed to be more annoying (those print("ss");
printN(23);-a print("aassaaas"); ) than printf
but im not fully comprehending this varargs stuff and i think i should
learn it (though its panful for old 50 year old man)
so the question is the passing down the variadic arguments costly?
how it work?
i mean when-a you got function that takes varargs like
-a-avoid slog_yellow(char *format, ...)
-a-a{
-a-a-a-a SlogColor(0xffff00);-a-a-a va_list args; va_start(args, format); >> slog(format, args);-a-a-a va_end(args);
-a-a}
and you pass it down to oryginal slog() which also takes varargs
void slog_(char *format, ...)
-a-a{
-a-a-a-a-a-a va_list args;
-a-a-a-a-a-a va_start(args, format);
-a-a-a-a-a int n =-a vsnprintf(&slog_[slog_top][0], slog_line_max, format, >> args);
-a-a-a-a-a-a va_end(args);
-a-a-a-a-aslog_top++;
}
which in turn as uit shows passes it down to vsnprintf
does this passing is costly?
Pass it through a preprocessor (-E option on many compilers) to see what those va-macros expand to.
As for efficiency, that will depend on compiler; some may inline such
code for example.
But if performing output that also involves binary to text conversion, that's already a bottleneck anyway.
but im not fully comprehending this varargs stuff and i think i
should learn it (though its panful for old 50 year old man)
On Fri, 11 Sep 2026 13:25:03 +0200, fir wrote:
but im not fully comprehending this varargs stuff and i think i
should learn it (though its panful for old 50 year old man)
DonrCOt worry about the internals of how it works, since that will very
much be architecture-specific. Just learn to use it, which is
basically quite simple. Just overlook the fact that itrCOs a gigantic
hole in the safenessrCa of the C type system.
One thing I have done is create Python wrappers around varargs calls
which can indeed be fully type-safe. This can be done entirely in
Python, without writing any C code, thanks to this wonderful library
module for creating wrappers, called ctypes <https://docs.python.org/3/library/ctypes.html>.
rCaHAHAHA etc
On Fri, 11 Sep 2026 13:25:03 +0200, fir wrote:
but im not fully comprehending this varargs stuff and i think i
should learn it (though its panful for old 50 year old man)
DonrCOt worry about the internals of how it works, since that will very
much be architecture-specific. Just learn to use it, which is
basically quite simple. Just overlook the fact that itrCOs a gigantic
hole in the safenessrCa of the C type system.
One thing I have done is create Python wrappers around varargs calls
which can indeed be fully type-safe. This can be done entirely in
Python, without writing any C code, thanks to this wonderful library
module for creating wrappers, called ctypes <https://docs.python.org/3/library/ctypes.html>.
rCaHAHAHA etc
Lawrence DrCOOliveiro pisze:
One thing I have done is create Python wrappers around varargs
calls which can indeed be fully type-safe.
ok it showed not so hard
for example implementation of
varar("iicffd", 1, 2, 'a', 9.f, 8.5f, 10.0);
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 74 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 121:16:15 |
| Calls: | 1,194 |
| Files: | 1,352 |
| Messages: | 290,208 |