-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Build fixes after previous C++ patch #1935
Conversation
VS 2013 doesn't accept certain C++11 constants like std::numeric_limits, so we have to return to the code used before that mentioned patch.
Can be enabled on demand.
runtime/Cpp/runtime/src/Recognizer.h
Outdated
@@ -11,7 +11,7 @@ namespace antlr4 { | |||
|
|||
class ANTLR4CPP_PUBLIC Recognizer { | |||
public: | |||
static const size_t EOF = std::numeric_limits<size_t>::max(); | |||
static const size_t EOF = (size_t)-1; // std::numeric_limits<size_t>::max(); doesn't work in VS 2013. |
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.
Would it be possible to use static_cast<size_t>(-1)
as an alternative? (here are elsewhere where there are old-style casts in this patch.)
Also: there is the INVALID_INDEX
#define at the end of antlr-common.h, which uses the same construct. Does VS2013 choke on use of that as well?
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.
Certainly doable, I just like to avoid lengthy cast expressions in simple cases like this (it's probably optimized away by the compiler).
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.
Neither type of cast will be have any runtime overhead. The reason I prefer static_cast over a C-style cast is that the compiler enforces that the cast is safe. That way, when examining code, you only need to look for occurrences of reinterpret_cast to check for potential unsafe casting. This is also a rule on one of Scott Meyer's "Effective C++" books.
Also fixed XCode tests.
@parrt Please merge this C++-only patch. People try to build from master and it fails due do missing project settings on Windows. |
This patch is for the C++ target only and contains fixes for compilation problems in VS and XCode after merging the last C++ patch. There is no functional change.