How to use core.vararg to print D variadic arguments and their types without using ! (template instantiation)?

BoQsc vaidas.boqsc at gmail.com
Mon Sep 18 09:22:11 UTC 2023


>
> Note that this doesn't work in gdc.
>
> The templated version is actually more akin to what C does.

Yeah it does not seem to work in gdc when tested using 
https://d.godbolt.org/

The errors produced:

```
<source>:11:12: error: none of the overloads of template 
'core.stdc.stdarg.va_arg' are callable using argument types 
'!()(__va_list_tag[1], TypeInfo, int*)'
    11 |      va_arg(_argptr, typeid(i), &i);
       |            ^
/opt/compiler-explorer/gcc-trunk-20230917/lib/gcc/x86_64-linux-gnu/14.0.0/include/d/core/stdc/stdarg.d:179:7: note: Candidates are: 'va_arg(T)(ref va_list ap)'
   179 |     T va_arg(T)(ref va_list ap); // intrinsic
       |       ^
/opt/compiler-explorer/gcc-trunk-20230917/lib/gcc/x86_64-linux-gnu/14.0.0/include/d/core/stdc/stdarg.d:291:10: note:                 'va_arg(T)(ref va_list ap, ref T parmn)'
   291 |     void va_arg(T)(ref va_list ap, ref T parmn); // 
intrinsic
       |          ^
<source>:14:12: error: none of the overloads of template 
'core.stdc.stdarg.va_arg' are callable using argument types 
'!()(__va_list_tag[1], TypeInfo, double*)'
    14 |      va_arg(_argptr, typeid(d), &d);
       |            ^
/opt/compiler-explorer/gcc-trunk-20230917/lib/gcc/x86_64-linux-gnu/14.0.0/include/d/core/stdc/stdarg.d:179:7: note: Candidates are: 'va_arg(T)(ref va_list ap)'
   179 |     T va_arg(T)(ref va_list ap); // intrinsic
       |       ^
/opt/compiler-explorer/gcc-trunk-20230917/lib/gcc/x86_64-linux-gnu/14.0.0/include/d/core/stdc/stdarg.d:291:10: note:                 'va_arg(T)(ref va_list ap, ref T parmn)'
   291 |     void va_arg(T)(ref va_list ap, ref T parmn); // 
intrinsic
       |          ^
ASM generation compiler returned: 1
<source>:11:12: error: none of the overloads of template 
'core.stdc.stdarg.va_arg' are callable using argument types 
'!()(__va_list_tag[1], TypeInfo, int*)'
    11 |      va_arg(_argptr, typeid(i), &i);
       |            ^
/opt/compiler-explorer/gcc-trunk-20230918/lib/gcc/x86_64-linux-gnu/14.0.0/include/d/core/stdc/stdarg.d:179:7: note: Candidates are: 'va_arg(T)(ref va_list ap)'
   179 |     T va_arg(T)(ref va_list ap); // intrinsic
       |       ^
/opt/compiler-explorer/gcc-trunk-20230918/lib/gcc/x86_64-linux-gnu/14.0.0/include/d/core/stdc/stdarg.d:291:10: note:                 'va_arg(T)(ref va_list ap, ref T parmn)'
   291 |     void va_arg(T)(ref va_list ap, ref T parmn); // 
intrinsic
       |          ^
<source>:14:12: error: none of the overloads of template 
'core.stdc.stdarg.va_arg' are callable using argument types 
'!()(__va_list_tag[1], TypeInfo, double*)'
    14 |      va_arg(_argptr, typeid(d), &d);
       |            ^
/opt/compiler-explorer/gcc-trunk-20230918/lib/gcc/x86_64-linux-gnu/14.0.0/include/d/core/stdc/stdarg.d:179:7: note: Candidates are: 'va_arg(T)(ref va_list ap)'
   179 |     T va_arg(T)(ref va_list ap); // intrinsic
       |       ^
/opt/compiler-explorer/gcc-trunk-20230918/lib/gcc/x86_64-linux-gnu/14.0.0/include/d/core/stdc/stdarg.d:291:10: note:                 'va_arg(T)(ref va_list ap, ref T parmn)'
   291 |     void va_arg(T)(ref va_list ap, ref T parmn); // 
intrinsic
       |          ^
Execution build compiler returned: 1
```


More information about the Digitalmars-d-learn mailing list