Skip to content

Conversation

@iboB
Copy link
Contributor

@iboB iboB commented Jul 10, 2024

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 from char. That's why u8"string" (being const char8_t*) cannot be implicitly cast to const char*. The PR adds a macro which performs the explicit cast if necessary

#if __cplusplus >= 202000L
#define LU8(x) (const char*)(u8##x)
#else
#define LU8(x) u8##x
Copy link
Collaborator

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.

Copy link
Contributor Author

@iboB iboB Jul 10, 2024

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.

#endif

#if __cplusplus >= 202000L
#define LU8(x) (const char*)(u8##x)
Copy link
Collaborator

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.

Copy link
Contributor Author

@iboB iboB Jul 10, 2024

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.

@ggerganov ggerganov merged commit cc61948 into ggml-org:master Jul 10, 2024
Nexesenex pushed a commit to Nexesenex/croco.cpp that referenced this pull request Jul 11, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Jul 13, 2024
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