www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Error: func(const(A) a) is not callable using argument types (const(A)

reply Andrew Edwards <edwards.ac gmail.com> writes:
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))
}
May 30 2017
next sibling parent reply Andrew Edwards <edwards.ac gmail.com> writes:
Sorry, rough day. Could someone please explain what this means 
and how do go about resolving it?

Thanks,
Andrew
May 30 2017
parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Tuesday, 30 May 2017 at 10:20:53 UTC, Andrew Edwards wrote:
 Sorry, rough day. Could someone please explain what this means 
 and how do go about resolving it?

 Thanks,
 Andrew
If you want to resolve it just do const label_size = CalcTextSize(...); but as others have mentioned make sure it is the right type (although if they are functionally identical it won't matter).
May 30 2017
prev sibling next sibling parent Daniel Kozak via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
It seems there are two different ImVec2 types. So ImVec2 is not same as ImVec2
:)

On Tue, May 30, 2017 at 12:09 PM, Andrew Edwards via Digitalmars-d-learn <
digitalmars-d-learn puremagic.com> 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))
 }
May 30 2017
prev sibling parent reply Biotronic <simen.kjaras gmail.com> writes:
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
May 30 2017
parent reply Daniel Kozak via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
import std.traits : fqn = fullyQualifiedName;

On Tue, May 30, 2017 at 12:24 PM, Biotronic via Digitalmars-d-learn <
digitalmars-d-learn 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
May 30 2017
parent reply Biotronic <simen.kjaras gmail.com> writes:
On Tuesday, 30 May 2017 at 10:31:24 UTC, Daniel Kozak wrote:
 import std.traits : fqn = fullyQualifiedName;
Darnit. I just googled the template and got a result talking about fqn!T. So yeah - this code: import std.traits; pragma(msg, fullyQualifiedName!ImVec2); pragma(msg, fullyQualifiedName!(typeof(CalcTextSize(label.ptr, null, true)))); -- Biotronic
May 30 2017
parent reply Andrew Edwards <edwards.ac gmail.com> writes:
On Tuesday, 30 May 2017 at 10:37:58 UTC, Biotronic wrote:
 On Tuesday, 30 May 2017 at 10:31:24 UTC, Daniel Kozak wrote:
 import std.traits : fqn = fullyQualifiedName;
Darnit. I just googled the template and got a result talking about fqn!T. So yeah - this code: import std.traits; pragma(msg, fullyQualifiedName!ImVec2); pragma(msg, fullyQualifiedName!(typeof(CalcTextSize(label.ptr, null, true)))); -- Biotronic
This is exactly the cause. Output is follows: internal.ImVec2 types.ImVec2 I'm leveraging types as I try to do my own port of the lib so CalcTextSize is returning an instance of ImVec2 as defined types and I'm trying to assign to one I have declared in internal. Thanks.
May 30 2017
parent reply Biotronic <simen.kjaras gmail.com> writes:
On Tuesday, 30 May 2017 at 10:46:12 UTC, Andrew Edwards wrote:
 On Tuesday, 30 May 2017 at 10:37:58 UTC, Biotronic wrote:
 On Tuesday, 30 May 2017 at 10:31:24 UTC, Daniel Kozak wrote:
 import std.traits : fqn = fullyQualifiedName;
Darnit. I just googled the template and got a result talking about fqn!T. So yeah - this code: import std.traits; pragma(msg, fullyQualifiedName!ImVec2); pragma(msg, fullyQualifiedName!(typeof(CalcTextSize(label.ptr, null, true)))); -- Biotronic
This is exactly the cause. Output is follows: internal.ImVec2 types.ImVec2 I'm leveraging types as I try to do my own port of the lib so CalcTextSize is returning an instance of ImVec2 as defined types and I'm trying to assign to one I have declared in internal. Thanks.
Pleasure. :) I don't know why you have two different ImVec2s, but you may have good reasons to. If they need to be separate, you'll need to write a conversion function between the two for the cases where you have one and want the other. This could be the constructor or opAssign, or a standalone function if you want to be more explicit about it. I'd argue that error message could be improved upon, btw. -- Simen
May 30 2017
parent Daniel Kozak via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
http://forum.dlang.org/post/xpmpakmusudanwuzzezl forum.dlang.org
https://issues.dlang.org/show_bug.cgi?id=9631

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

 On Tuesday, 30 May 2017 at 10:46:12 UTC, Andrew Edwards wrote:

 On Tuesday, 30 May 2017 at 10:37:58 UTC, Biotronic wrote:

 On Tuesday, 30 May 2017 at 10:31:24 UTC, Daniel Kozak wrote:

 import std.traits : fqn = fullyQualifiedName;
Darnit. I just googled the template and got a result talking about fqn!T. So yeah - this code: import std.traits; pragma(msg, fullyQualifiedName!ImVec2); pragma(msg, fullyQualifiedName!(typeof(CalcTextSize(label.ptr, null, true)))); -- Biotronic
This is exactly the cause. Output is follows: internal.ImVec2 types.ImVec2 I'm leveraging types as I try to do my own port of the lib so CalcTextSize is returning an instance of ImVec2 as defined types and I'm trying to assign to one I have declared in internal. Thanks.
Pleasure. :) I don't know why you have two different ImVec2s, but you may have good reasons to. If they need to be separate, you'll need to write a conversion function between the two for the cases where you have one and want the other. This could be the constructor or opAssign, or a standalone function if you want to be more explicit about it. I'd argue that error message could be improved upon, btw. -- Simen
May 30 2017