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);ÿ 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ÿ you got function that takes varargs like
ÿvoid slog_yellow(char *format, ...)
ÿ{
ÿÿÿ SlogColor(0xffff00);ÿÿÿ va_list args; va_start(args, format); slog(format, args);ÿÿÿ va_end(args);
ÿ}
and you pass it down to oryginal slog() which also takes varargs
void slog_(char *format, ...)
ÿ{
ÿÿÿÿÿ va_list args;
ÿÿÿÿÿ va_start(args, format);
ÿÿÿÿ int n =ÿ vsnprintf(&slog_[slog_top][0], slog_line_max, format, args);
ÿÿÿÿÿ va_end(args);
ÿÿÿÿslog_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);ÿ 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ÿ you got function that takes varargs like
ÿvoid slog_yellow(char *format, ...)
ÿ{
ÿÿÿ SlogColor(0xffff00);ÿÿÿ va_list args; va_start(args, format); slog(format, args);ÿÿÿ va_end(args);
ÿ}
and you pass it down to oryginal slog() which also takes varargs
void slog_(char *format, ...)
ÿ{
ÿÿÿÿÿ va_list args;
ÿÿÿÿÿ va_start(args, format);
ÿÿÿÿ int n =ÿ vsnprintf(&slog_[slog_top][0], slog_line_max, format, args);
ÿÿÿÿÿ va_end(args);
ÿÿÿÿslog_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);ÿ 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ÿ you got function that takes varargs like
ÿÿvoid slog_yellow(char *format, ...)
ÿÿ{
ÿÿÿÿ SlogColor(0xffff00);ÿÿÿ va_list args; va_start(args, format);
slog(format, args);ÿÿÿ va_end(args);
ÿÿ}
and you pass it down to oryginal slog() which also takes varargs
void slog_(char *format, ...)
ÿÿ{
ÿÿÿÿÿÿ va_list args;
ÿÿÿÿÿÿ va_start(args, format);
ÿÿÿÿÿ int n =ÿ vsnprintf(&slog_[slog_top][0], slog_line_max, format,
args);
ÿÿÿÿÿÿ va_end(args);
ÿÿÿÿÿslog_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)
Don?t 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 it?s a gigantic
hole in the safeness? 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>.
?HAHAHA 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)
Don?t 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 it?s a gigantic
hole in the safeness? 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>.
?HAHAHA etc
Lawrence D?Oliveiro 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: | Tetrazocine |
|---|---|
| Location: | Melbourne, VIC, Australia |
| Users: | 8 |
| Nodes: | 8 (0 / 8) |
| Uptime: | 14:40:39 |
| Calls: | 220 |
| Files: | 21,513 |
| Messages: | 83,058 |