Compile time macro trouble.
Dan Olson via digitalmars-d-ldc
digitalmars-d-ldc at puremagic.com
Sun Mar 13 07:34:15 PDT 2016
Dan Olson <gorox at comcast.net> writes:
> Taylor Hillegeist <taylorh140 at gmail.com> writes:
>
>> I'm just trying to get more comfortable with working on
>> microcontrollers with d. The good news is that I got a simple example
>> running. An led blinking three colors!
That is cool!
> Taylor, this should help:
>
> Change your function to a template, and then it will get inlined (add the
> extra, empty parens).
>
> uint32_t SIM_SOPT2_TPMSRC()(uint32_t x) {
> return ((x << SIM_SOPT2_TPMSRC_SHIFT) & SIM_SOPT2_TPMSRC_MASK);
> }
>
> I think LDC only inlines regular functions when they are in the same
> module. But templates get inlined across modules.
>
> Make sure you are using LDC ltsmaster branch since it has some needed
> improvements for ARM, although thumb is not well tested except on iOS
> (but that is a different fork).
Oh, and compile with optimizer -O to get template inlining.
More information about the digitalmars-d-ldc
mailing list