Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling convention needed on a few functions #182

Closed
jrouwe opened this issue Feb 2, 2019 · 4 comments
Closed

Calling convention needed on a few functions #182

jrouwe opened this issue Feb 2, 2019 · 4 comments

Comments

@jrouwe
Copy link

jrouwe commented Feb 2, 2019

I'm compiling my project with the __vectorcall calling convention (/Gv) on MSVC which causes doctest to throw up a few compile errors:

doctest.h(5016): error C2664: 'void qsort(void *,size_t,size_t,_CoreCrtNonSecureSearchSortCompareFunction)': cannot convert argument 4 from 'int (__vectorcall *)(const void *,const void *)' to '_CoreCrtNonSecureSearchSortCompareFunction' doctest.h(5016): note: None of the functions with this name in scope match the target type doctest.h(5018): error C2664: 'void qsort(void *,size_t,size_t,_CoreCrtNonSecureSearchSortCompareFunction)': cannot convert argument 4 from 'int (__vectorcall *)(const void *,const void *)' to '_CoreCrtNonSecureSearchSortCompareFunction' doctest.h(5018): note: None of the functions with this name in scope match the target type doctest.h(5020): error C2664: 'void qsort(void *,size_t,size_t,_CoreCrtNonSecureSearchSortCompareFunction)': cannot convert argument 4 from 'int (__vectorcall *)(const void *,const void *)' to '_CoreCrtNonSecureSearchSortCompareFunction' doctest.h(5020): note: None of the functions with this name in scope match the target type doctest.h(5260): warning C4007: 'main': must be '__cdecl'

To fix them I had to add __cdecl to the functions fileOrderComparator, suiteOrderComparator, nameOrderComparator and main.

I'm only targetting Windows and Linux so this works for me, but I don't believe OS X supports the __cdecl calling convention, so my guess is that it is best to add a macro to specify the default calling convention for those methods.

Regards,

Jorrit.

@onqtam
Copy link
Member

onqtam commented Feb 3, 2019

Hi! I'll get to this in a few days (or perhaps a week+).

@onqtam
Copy link
Member

onqtam commented Feb 4, 2019

I'm puzzled as to why there is a problem for main() as well and not many of the other functions... I found that imgui have had a similar issue reported, so I guess I'll do something similar for doctest: ocornut/imgui#1230 and ocornut/imgui#1611

EDIT: actually microsoft state it in their docs about main... but instead of annotating it I'll just ignore the warning there

onqtam added a commit that referenced this issue Feb 4, 2019
@onqtam
Copy link
Member

onqtam commented Feb 4, 2019

@jrouwe actually I just moved away from qsort and now using C++ std::sort where there shouldn't be such a problem. Also silencing the warning around main.

Try the dev branch and let me know if it's fixed. Not sure when I'll release this in the master branch though...

@jrouwe
Copy link
Author

jrouwe commented Feb 5, 2019

Hello,

I can confirm that it works. Thanks for the quick fix!

Regards,
Jorrit

@jrouwe jrouwe closed this as completed Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants