-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
Tests don't compile with MSVC (Windows) #174
Comments
Are the folks on the Unity project aware of this issue? Is there a related issue on their repo? |
I should clarify, according to their docs those functions are required unless "you're using a compiler that is configured to make these functions optional". So really it's an issue on us for only supporting gcc/clang. |
@patricksjackson I'm not really familiar with building C on Windows without Cygwin (ugh) or MinGW (slightly less ugh). I thought that MSVC wasn't even C99 compliant. So, is there a way for someone to easily set up MSVC to build our C99 code? Where would you get make if you just installed the Microsoft tools? Basically, is this something worth supporting, or is it so painful that the crappy GNU options are actually better? |
FYI, MSVC doesn't really support C99. It supports it insofar as updates to the C++ compiler also apply to some C code. MS picked C++ over C as their language of choice for native code. There is a discussion on it here https://social.msdn.microsoft.com/Forums/SECURITY/en-US/fa17bcdd-7165-4645-a676-ef3797b95918/details-on-c99-support-in-msvc?forum=vcgeneral Although, this stance seems to vary depending on which way the wind is blowing and MSVC version: https://stackoverflow.com/questions/9610747/which-c99-features-are-available-in-the-ms-visual-studio-compiler The most specific official details I've found on support are here https://msdn.microsoft.com/en-us/library/hh567368.aspx?f=255&MSPPError=-2147217396. For my 2c: I've struggled getting MinGW/MYSYS setup before but did get it working to differing degrees on various occasions. GCC on WSL though is a much (much) easier-to-use alternative to recommend. For these reasons I would recommend being wary of adding specific support for MSVC building. For the specific case in this issue, the |
@wolf99 Thanks for all the background. I agree with you: the specific case of |
FWIW, Visual Studio works to build the exercises pretty easily. I haven't tried to use the Makefiles (you're supposed to be able to import them I think) but you can just make an empty project pointed to the exercise directory and it sets everything up for you. It's a useful alternative if the people doing the exercises are in Windows and have never used the command line, or would just rather have the VS capabilities. @wolf99 WSL is also my recommendation for getting the Unix tools on Windows :) The only issue I've had recently is with tools that don't handle CRLF line endings. I'd also agree that making non-standard changes to support a particular compiler vendor isn't the best plan, but this change is the exact opposite. The only reason it currently works is because Unity wrote non-standard workarounds for GCC/Clang. Also, it's really not worthwhile to try to get Unity to support Weak Symbols for every compiler (or even just adding MSVC), I mentioned it but it's not worth it when |
* Start sublist * Finish tests and example * Run indent script * Add additional test for signed integer * Add exercise to config.json * Update README * Update per review comments * Ignore all tests except for the first one * Refactor naming * Formatter * Add setUp and tearDown per #174; add comment to first TEST_IGNORE() * Switch sublist to non-core
TLDR - There are issues with doing the exercises under Visual Studio (and likely other non-GCC/Clang compilers like ICC). This can be fixed by adding the following function defs to all of the
test\test_*.c
files.This is because Unity uses a non-standard method to support optional
setUp
andtearDown
methods. GCC and Clang methods are implemented in Unity (they support__attribute__((weak))
and/or#pragma weak
I think). Other compilers may do the same, but MSVC doesn't support those as far as I can tell.Someone could fix the issue for us by patching Unity with the correct method for MSVC (you can pass comments to the linker using a pragma), but that doesn't fix it for other compilers that don't support the weak linking either.
It does work fine using the various unix implementations on Windows (WSL and MSYS) since they just use GCC.
The text was updated successfully, but these errors were encountered: