[Issue 1301] CTFE fails for ImportExpressions
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Sat Jun 30 11:00:44 PDT 2007
d-bugmail at puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=1301
>
>
>
>
>
> ------- Comment #2 from samukha at voliacable.com 2007-06-30 12:27 -------
> Oops. Thanks for pointing that out.
>
>
One thing I think should work is hiding the import() in a template, and
sending that value off to the CTF.
template T_Import (char[] file) {
const T_Import = import(file);
}
template T_Foo (char[] file) {
const T_Foo = `foo("`~T_Import!(file)~`")` ;
}
char[] foo (char[] data) {
// ...
}
void main (char[][] args) {
mixin(T_Foo!("template"));
}
I've used something similar to preload image and font data in an SDL
based program. It does work -- and the extra T_Import template
maintains one copy of a given file being embedded. (Otherwise fonts at
least would sometimes result in two or three copies. Bad bad disc
usage, that.)
-- Chris Nicholson-Sauls
More information about the Digitalmars-d-bugs
mailing list