-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
llama : C++20 compatibility for u8 strings #8408
Conversation
#if __cplusplus >= 202000L | ||
#define LU8(x) (const char*)(u8##x) | ||
#else | ||
#define LU8(x) u8##x |
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.
why prefix the macro with L
? , that makes it seem like it is a wide string.
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.
as in llama, could be T
as well. I wanted three characters to minimize the risk of collisions, as simply U8
looks risky.
@@ -57,6 +57,12 @@ | |||
#include <io.h> | |||
#endif | |||
|
|||
#if __cplusplus >= 202000L | |||
#define LU8(x) (const char*)(u8##x) |
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.
you should use a proper cast, instead of a c-style one.
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.
Why? It's not like there are any "proper" casts in the file itself. All other casts are C-style.
This PR fixes the compilation errors when compiling with C++20 (which may come from above incase llama.cpp is a subdir)
In C++20
char8_t
is distinct fromchar
. That's whyu8"string"
(beingconst char8_t*
) cannot be implicitly cast toconst char*
. The PR adds a macro which performs the explicit cast if necessary