Can we check the arguments to format() at compile time?
Yuxuan Shui via Digitalmars-d
digitalmars-d at puremagic.com
Fri Apr 1 14:25:46 PDT 2016
Clang has this nice feature that it will warn you when you passed
wrong arguments to printf:
#include <stdio.h>
int main(){
long long u = 10;
printf("%c", u);
}
clang something.c:
something.c:4:15: warning: format specifies type 'int' but the
argument has type 'long long' [-Wformat]
With the CTFE power of D, we should be able to do the same thing
when the format string is available at compile time. Instead of
throwing exceptions at run time.
More information about the Digitalmars-d
mailing list