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

CMake and no-warn MSVC support #118

Open
wants to merge 4 commits into
base: release
Choose a base branch
from

Conversation

SamuelMarks
Copy link

WiP but it currently builds fine on Windows (no warning).

PS: In terms of strncat_s I suppose I can guard that rather than include an implementation (if you prefer).

Copy link
Owner

@silentbicycle silentbicycle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should target the develop branch, as noted at the beginning of CONTRIBUTING.md. master will be renamed to release eventually, changes are only merged there as part of versioned releases.

Should this be a draft PR? ("WiP but it currently builds fine on Windows (no warning).")

I currently don't use Windows at all, so I won't be able to test this.

@@ -56,6 +63,34 @@ TEST just_fail(void) {
FAIL();
}

#if defined(_MSC_VER) || defined(__MINGW32__)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than adding a substitute implementation of gettimeofday here, it could just call GetSystemTime and SystemTimeToFileTime then use the milliseconds field. Actually replicating the overall behavior of gettimeofday isn't important -- it's just grabbing a timestamp to use as a seed for example code.

greatest.h Outdated
@@ -700,6 +700,99 @@ typedef enum greatest_test_res {
prng->count_run = prng->random_order = prng->initialized = 0; \
} while(0)

#if defined(__STDC_LIB_EXT1__) || defined(_MSC_VER) || defined(__MINGW32__)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really necessary? strnlen and strncat are in the C standard library.

Note the bit in the README about the LOC limit -- this would exceed that, considerably.

Also, it adds a substantial block of code with a different license. I'd really prefer to avoid doing that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but strnlen_s and strncat_s are missing.

Again happy to remove the code and just use a different macro-branch for MSVC, the goal is to get it to compile in MSVC without throwing any warnings related to https://learn.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go in contrib/, as should the cmake directory, to make it clear that this is a contributed extension rather than something necessary for using it. I haven't used cmake much, so I won't actively maintain it myself.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to move the cmake directory to contrib but without a CMakeLists.txt in project root others cloning this repo won't realise that it has CMake integrated. E.g., whence cloning in an IDE like CLion.

@SamuelMarks SamuelMarks marked this pull request as draft May 7, 2023 14:24
@SamuelMarks SamuelMarks marked this pull request as ready for review May 9, 2023 19:38
@foxx
Copy link

foxx commented Jun 7, 2023

As a temporary workaround, this will at least make things compile:

#pragma warning( push )
#pragma warning( disable: 4996)
GREATEST_MAIN_DEFS();
#pragma warning( pop )

However, it would be nice if Greatest used the security enhanced CRT functions when compiling for windows.

I'd be happy to help with any testing etc if that would help push a fix through for next release.

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

Successfully merging this pull request may close these issues.

3 participants