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

snitch doesn't compile #129

Closed
s9w opened this issue Sep 28, 2023 · 7 comments · Fixed by #130
Closed

snitch doesn't compile #129

s9w opened this issue Sep 28, 2023 · 7 comments · Fixed by #130
Labels
bug:confirmed Something isn't working (confirmed)
Milestone

Comments

@s9w
Copy link

s9w commented Sep 28, 2023

context: 1.2.2 release, header-only mode, newest VS (17.8.0 preview 2)

Even compiling a trivial

#define SNITCH_IMPLEMENTATION
#include <snitch/snitch_all.hpp>

TEST_CASE("Factorials are computed", "[factorial]") {
   REQUIRE(true);
}

results in error C2397: conversion from 'long' to 'size_t' requires a narrowing conversion

@s9w
Copy link
Author

s9w commented Sep 28, 2023

I think I nailed it down to this line, specifically the __LINE__ macro. That might need a cast or something as it gets assigned to your std::size_t line member.

@cschreib
Copy link
Member

cschreib commented Sep 28, 2023

Thanks for reporting this, and indeed that was my suspicion as well. A cast in the macro should fix it. Feel free to open a PR, otherwise I will do it tomorrow or this weekend.

NB there are a few places where this will be needed
https://github.com/cschreib/snitch/blob/87260edd26c2005a7b8998130dc7e92fb15aef52/include/snitch/snitch_macros_test_case.hpp#L11
https://github.com/cschreib/snitch/blob/87260edd26c2005a7b8998130dc7e92fb15aef52/include/snitch/snitch_macros_test_case.hpp#L22
etc...

@cschreib cschreib added the bug:confirmed Something isn't working (confirmed) label Sep 28, 2023
@cschreib cschreib added this to the v1.2.3 milestone Sep 28, 2023
@cschreib
Copy link
Member

A neater alternative would be to use std::source_location, but I was worried of the potential compilation time overhead. Perhaps unjustifiably so since I never measured it.

@s9w
Copy link
Author

s9w commented Sep 28, 2023

This was probably more or less the exact place for which std::source_location was intended, so I'd give it a go yeah.

@cschreib
Copy link
Member

a7d9e46 should fix the problem, if you get a chance to test it.

I'm refraining from using std::source_location for now. Its main advantage is that it doesn't require macros, but since snitch checks are macro-based, this isn't something we really benefit from. It would just create overhead, since eventually we want to store a {std::string_view, std::size_t}, that it would need converting into. It will be more useful when reflection comes in and can decompose expressions without macros, then snitch can become mostly macro-free. But we're not there yet!

@s9w
Copy link
Author

s9w commented Sep 30, 2023 via email

@cschreib
Copy link
Member

cschreib commented Oct 5, 2023

Merged and released; I assumed all went fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:confirmed Something isn't working (confirmed)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants