Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #387479
| Path | csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
| Newsgroups | comp.lang.c |
| Subject | Re: is it possible to have functions with 0, 1, or 2 args? |
| Date | Sun, 11 Aug 2024 10:43:03 -0700 |
| Organization | A noiseless patient Spider |
| Lines | 38 |
| Message-ID | <86y153klaw.fsf@linuxsc.com> (permalink) |
| References | <7q-dnbTDU4oBES37nZ2dnZfqnPednZ2d@brightview.co.uk> <macros-20240805103134@ram.dialup.fu-berlin.de> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Date | Sun, 11 Aug 2024 19:43:04 +0200 (CEST) |
| Injection-Info | dont-email.me; posting-host="e27eccf1f18fd326d4b617bedae077c0"; logging-data="2949741"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rflmRdf39xIr7yhdlum7qmn+tN4/cUAY=" |
| User-Agent | Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) |
| Cancel-Lock | sha1:3IuA+WE267Nb1om8FDiHIw0nylU= sha1:YFcl57ofk8l/ufN+NZv4gx8bQh4= |
| Xref | csiph.com comp.lang.c:387479 |
Show key headers only | View raw
ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Mark Summerfield <mark@qtrac.eu> wrote or quoted:
>
>> This does *not* work for the `va_test()` call. But if I supply 1 or 2 args
>> it works great.
>
> Here's an
>
> SSCCE, a short self-contained correct compilable example, aka,
> MWE - minimal working example.
>
> Some coders whip up these examples themselves for their post!
>
> It's a quick and dirty demo that can be compiled and run to
> show what's buggin' them.
>
> In this case, it's hella clear the macros are trippin', thinkin'
> the number of args is "1" when it's actually zilch, nada, zero.
>
> main.c
>
> #include <stdio.h>
>
> #define NARGS(...) NARGS_(__VA_ARGS__, 5, 4, 3, 2, 1, 0)
> #define NARGS_(_5, _4, _3, _2, _1, N, ...) N
> #define va_test(...) NARGS(__VA_ARGS__)
>
> int main( void ){ printf( "%d\n", va_test() ); }
>
> transcript
>
> 1
It appears you have missed the point of the question. What is being
sought is a way to distinguish between macro calls like va_test()
and macro calls like va_test(x). The above definition of va_test()
doesn't do that.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
is it possible to have functions with 0, 1, or 2 args? Mark Summerfield <mark@qtrac.eu> - 2024-08-05 08:26 +0000
Re: is it possible to have functions with 0, 1, or 2 args? Michael S <already5chosen@yahoo.com> - 2024-08-05 15:19 +0300
Re: is it possible to have functions with 0, 1, or 2 args? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 22:20 -0700
Re: is it possible to have functions with 0, 1, or 2 args? Richard Harnden <richard.nospam@gmail.invalid> - 2024-08-12 09:33 +0100
Re: is it possible to have functions with 0, 1, or 2 args? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-12 02:28 -0700
Re: is it possible to have functions with 0, 1, or 2 args? Richard Harnden <richard.nospam@gmail.invalid> - 2024-08-12 11:37 +0100
Re: is it possible to have functions with 0, 1, or 2 args? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-12 15:39 -0700
Re: is it possible to have functions with 0, 1, or 2 args? Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2024-08-05 18:46 +0000
Re: is it possible to have functions with 0, 1, or 2 args? Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-08-07 23:04 +0000
Re: is it possible to have functions with 0, 1, or 2 args? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 10:43 -0700
Re: is it possible to have functions with 0, 1, or 2 args? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 22:15 -0700
csiph-web