Error: func(const(A) a) is not callable using argument types (const(A)

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 30 03:31:24 PDT 2017


import std.traits : fqn = fullyQualifiedName;

On Tue, May 30, 2017 at 12:24 PM, Biotronic via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> On Tuesday, 30 May 2017 at 10:09:50 UTC, Andrew Edwards wrote:
>
>> What does that even mean?
>>
>> Scenario:
>>
>> bool func(const ImVec2 label_size)
>> {
>>     return true;
>> }
>>
>> void main()
>> {
>>     //first attempt:
>>     const ImVec2 label_size = CalcTextSize(label.ptr, null, true);
>>     //Error: cannot implicitly convert expression
>> (CalcTextSize(cast(immutable(char)*)label, null, true, -1F)) of type
>> ImVec2 to const(ImVec2)
>>
>>     //second attempt
>>     const ImVec2 label_size = cast(const)CalcTextSize(label.ptr, null,
>> true);
>>     // Error: cannot implicitly convert expression
>> (CalcTextSize(cast(immutable(char)*)label, null, true, -1F)) of type
>> const(ImVec2) to const(ImVec2)
>>
>>     //third attempt
>>     const auto label_size = CalcTextSize(label.ptr, null, true);
>>     //Okay: don't know why the other two didn't work but I can keep going
>> for now
>>
>>     func(label_size);
>>     //Error: function imgui_d.func (const(ImVec2) label_size) is not
>> callable using argument types (const(ImVec2))
>> }
>>
>
> My immediate thought is 'is that the same ImVec2?' Do you have two
> definitions of ImVec2 laying about?
>
> What's the output of this code, if you insert it somewhere in the above?
>
> import std.traits;
>
> pragma(msg, fqn!ImVec2);
> pragma(msg, fqn!(typeof(CalcTextSize(label.ptr, null,
>
>> true))));
>>
>
> --
>   Biotronic
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20170530/db69a852/attachment.html>


More information about the Digitalmars-d-learn mailing list