-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fixes Jsrt API C99/C++98 compatability #2001
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
Conversation
Hi @jcoffland, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
@jcoffland, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
@jcoffland could you please squash the commits ? That should also trigger CI |
@@ -71,6 +71,10 @@ typedef BYTE* ChakraBytePtr; | |||
#define CHAKRA_API extern "C" SET_API_VISIBILITY JsErrorCode | |||
#else | |||
#define CHAKRA_API extern SET_API_VISIBILITY JsErrorCode | |||
#include <stdbool.h> | |||
#endif | |||
#if !defined(__cplusplus) || (__cplusplus <= 199711L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick: Could you please insert a blank line before this #if
for readability?
Ok, I've added the whitespace and squashed the commits. |
Any chance this will get merged? It's a very basic fix and I followed all the guidelines. Will someone please take responsibility for merging this PR? |
@jcoffland CI has been failing on this PR weirdly. Could you please try squash (still seeing 3 commits) and rebase onto latest master and force push your PR? Thanks! |
8a87583
to
348bf15
Compare
Ok, I believe I've sorted it out. I had already squashed my commits but then updated my fork by doing a merge which added extra commits to this PR. I fixed this by redoing the fork update as a rebase. |
@dotnet-bot test this please |
Did a search and found
Looks current |
@jianchun good catch. I found the line you quoted above https://github.com/Microsoft/ChakraCore/blob/master/bin/ch/ch.cpp#L275. I did a little investigating and found that Abusing |
Hi @jcoffland, you are 100% correct that I was doing some parameter hijacking. I agree with you that this is suboptimal and converting the API to use a second parameter instead is more appropriate (thanks for your help cleaning this up). One comment I have is that kthEvent is an optional parameter so we should probably make that clear in the SAL annotation/name. @jianchun we will need to update the use of this API in the node/xplat branch when we merge later as well. |
@mrkmarron right. I've now changed the parameter annotation from |
Question for ChakraCore maintainers: Is it possible to add a sort of test suite which exercises the use of our API when embedding ChakraCore in C99 and C++98 projects (using legacy build compatibility modes in vc and/or clang)? On that note, @liminzhu, I remember someone mentioning that one or more samples had broken when we updated the API. Should we think about including a set of tests that include the samples to ensure we don't unexpectedly break anything? (I guess we could clone the repo https://github.com/Microsoft/Chakra-Samples as a step in the tests, or include it as a submodule of ChakraCore for this purpose.) |
On another note: Should this fix be back-ported to release/1.4, release/1.3, and/or release/1.2 because we still support 1.2 and 1.3, and we had intended this to work? |
It wasn't an issue in 1.3 when I tried it. |
@jcoffland Thanks for confirming that. In any case, I think this PR should probably be re-targeted to 1.4 (because I'm pretty sure this issue would affect that release). But, hold off on that until we confirm. Worst-case we can just merge to master and then back-port the change to 1.4. |
@dilijev We already test that for some time. See https://github.com/Microsoft/ChakraCore/tree/master/test/native-tests |
@obastemur Do those tests check that the samples in https://github.com/Microsoft/Chakra-Samples work? |
@jcoffland AFAIK we do check a bit more here. However, we should add more tests there indeed. |
It would make sense to trigger CI builds on https://github.com/Microsoft/Chakra-Samples to make sure they build. It would be best to have CI build badges on that project's README.md. The reason being that the samples are one of the first places new users start with ChakraCore. If it doesn't work they are likely to go elsewhere. |
I am not sure if I was being clear. We already build and test the Jsrt usage (with the same xplat compile scripts and same code) on ChakraCore CI for each PR. If CI here is not failing, it is unlikely that we break Chakra-Samples. That is what https://github.com/Microsoft/ChakraCore/tree/master/test/native-tests for. |
@obastemur What keeps native-tests in sync with Chakra-Samples? My experience when I tried building Chakra-Samples was that they would not compile against ChakraCore Anyway, I've gone off topic. Can this PR be merged now? |
We do. Anything is failing on native tests, should alert devs to update Chakra Samples. IMHO it is similar to updating documentation. |
Fixed abuse of JsTTDMoveMode enum in call to JsTTDGetSnapTimeTopLevelEventMove() so that JsTTDMoveMode does not need to be 64-bit and thus incompatible with C99/C++98 Don't use nullptr at all, it's incompatible with C++98
This issue will affect release/1.4 so we should probably backport from master to release/1.4 it at a minimum. Other than that, LGTM and good to merge. |
@obastemur while this seems true in principle, I think it is easy to miss, and since, unlike documentation (which, except for JSRT APIs where we look closely at public documentation, is basically best-effort), Samples are something which we expect to work and which we can actually break. People new to the project would expect it to work right out of the box without having to work through any issues. I think we should seriously think about adding some automated test mechanism to ensure they all continue to work. /cc @liminzhu |
Assigning myself. I'll test and merge. |
Merge pull request #2001 from CauldronDevelopmentLLC:master
It should be noted that there are additional compile problems using the Jsrt API with the MSVC compiler in C mode that are not addressed by this PR. Thanks for the merge! |
@jcoffland Thanks for the heads-up. Could you open an issue so we can track those issues? |
…ak again Merge pull request #2136 from obastemur:add_c99_test #2001 fixes Jsrt C99/C++98 compatibility issue. @dilijev brought the idea of adding a test to make sure we don't break it again. This native test should take care of that. p.s.: This PR will break until #2001 is merged. /cc @dilijev @jcoffland
ChakraCore.h
appears to desire compatibility with C99 however this is currently broken due to the use ofnullptr
,bool
and C++11 style enums. Fortunately these problems are easily remedied.