How to import for mixin contents only.
Taylor Hillegeist via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Mar 9 21:01:30 PST 2016
On Thursday, 10 March 2016 at 04:56:52 UTC, Mike Parker wrote:
> On Thursday, 10 March 2016 at 04:07:54 UTC, Taylor Hillegeist
> wrote:
>> So i want bitfields for just a little bit. but i dont want its
>> dependencies. How is it done. I have tried this. but it doesnt
>> seem to work on gdc. :(
>>
>> struct Color_t {
>> static if(__ctfe){
>> import std.bitmanip:bitfields;
>> }
>> mixin(bitfields!(
>> uint, "R", 8,
>> uint, "G", 8,
>> uint, "B", 8,
>> uint, "A", 8));
>> }
>
> __ctfe is a runtime construct, not compile-time. It cannot be
> used with static if. More over, it's only available *inside* a
> function that is currently being executed in a compile-time
> context. It has no role outside of that.
>
> What problem are you trying to solve here? I mean, what is the
> problem with whatever dependencies std.bitmanip:bitfields has
> that makes you only want to import it during compilation?
I am running on a MKL25Z development board. The output of the
mixin works fine. but the dependencies of the
std.bitmanip:bitfields are quite extensive. including
std.format..etc
More information about the Digitalmars-d-learn
mailing list