www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D error messages for function call mismatches

reply FoxyBrown <Foxy Brown.IPT> writes:
D's error messaging is terrible in some ways. I am trying to get 
some code to work and this is the error:

arsd\stb_truetype.d(1246): Error: function core.stdc.stdlib.qsort 
(scope void* base, uint nmemb, uint size, extern (C) int 
function(scope const(void*), scope const(void*))  system compar) 
is not callable using argument types (void*, int, uint, extern 
(C) int function(const(void*) p, const(void*) q))

Find the bug!

Why can't D just dive a bit further and tell me the actual 
parameter(s) that it failing on? It obviously knows this as it 
has to check each one to know if there is an error. It should 
make it clear so I don't have to hunt and peck for the error. 
These lines don't always get wrapped in all cases so it is a 
scrollfest trying to find it.

Do the lead programmers for D use Visual D? Or do they use a 
specific tool chain that exhibits a specific behavior that they 
assume translates in to every other case?
Jun 27
next sibling parent tetyys <tetyys tetyys.com> writes:
On Tuesday, 27 June 2017 at 14:29:05 UTC, FoxyBrown wrote:
 arsd\stb_truetype.d(1246): Error: function 
 core.stdc.stdlib.qsort (scope void* base, uint nmemb, uint 
 size, extern (C) int function(scope const(void*), scope 
 const(void*))  system compar) is not callable using argument 
 types (void*, int, uint, extern (C) int function(const(void*) 
 p, const(void*) q))

 Find the bug!
well for starters you're passing an int to nmemb paramater
Jun 27
prev sibling next sibling parent Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
On Tuesday, 27 June 2017 at 14:29:05 UTC, FoxyBrown wrote:
 D's error messaging is terrible in some ways. I am trying to 
 get some code to work and this is the error:
This PR will improve the situation: https://github.com/dlang/dmd/pull/6806
Jun 27
prev sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 27 June 2017 at 14:29:05 UTC, FoxyBrown wrote:
 D's error messaging is terrible in some ways. I am trying to 
 get some code to work and this is the error:
I agree, that error message is terrible, and that's why I have a PR open to change it. But this specific case is weird to me too. stb_truetype.d is a port from C code, and I use it without any compile errors. Did you modify the code?
 Find the bug!
Even worse, I don't even see an error in that error message. The arguments it lists look acceptable.
Jun 27
parent FoxyBrown <Foxy Brown.IPT> writes:
On Tuesday, 27 June 2017 at 15:01:41 UTC, Adam D. Ruppe wrote:
 On Tuesday, 27 June 2017 at 14:29:05 UTC, FoxyBrown wrote:
 D's error messaging is terrible in some ways. I am trying to 
 get some code to work and this is the error:
I agree, that error message is terrible, and that's why I have a PR open to change it. But this specific case is weird to me too. stb_truetype.d is a port from C code, and I use it without any compile errors. Did you modify the code?
 Find the bug!
Even worse, I don't even see an error in that error message. The arguments it lists look acceptable.
Hi Adam, Yeah, I don't know, I think I had it working before but now it seems a lot of your code is not working. I did not change the std_truetype.d file. Just to make sure I copied and pasted the git source in to the original. alias STBTT_sort = core.stdc.stdlib.qsort; Is it possible that core.stdc.stdlib.qsort changed? void qsort(scope void* base, size_t nmemb, size_t size, _compare_fp_t compar); arsd\stb_truetype.d(1251): Error: function core.stdc.stdlib.qsort (scope void* base, uint nmemb, uint size, extern (C) int function(scope const(void*), scope const(void*)) system compar) is not callable using argument types (void*, uint, uint, extern (C) int function(const(void*) p, const(void*) q)) I changed your variables to size_t and they obviously match. The things that don't match are the scope's. qsort(scope void* base, uint nmemb, uint size, extern (C) int function(scope const(void*), scope const(void*)) system compar) (void*, uint, uint, extern (C) int function(const(void*) p, const(void*) q)) I am also getting a run time error with your png loading module. void popFront () { bufpos = 0; while (plpos != plpos.max && bufpos < chunkSize) { // do we have some bytes in zstream? if (zs.avail_in > 0) { // just unpack zs.next_out = cast(typeof(zs.next_out))(buffer.ptr+bufpos); int rd = chunkSize-bufpos; zs.avail_out = rd; auto err = inflate(&zs, Z_SYNC_FLUSH); if (err != Z_STREAM_END && err != Z_OK) throw new Exception("PNG unpack error"); Errors out with unpack error. This code used to work so it is probably on my system.
Jun 27