Skip to content
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

ggml: fix ms compiler error involving restrict keyword #1238

Closed
wants to merge 1 commit into from

Conversation

grahameth
Copy link
Contributor

Use __restrict instead of restrict on MS compiler to prevent compiler error on VS2017 and VS2019.

@slaren
Copy link
Member

slaren commented Apr 29, 2023

Can you help me understand what does this exactly enable? Isn't building with MSVC already supported? I can build without issue (well, other than the million of warnings) with VS 2019 Community.

@grahameth
Copy link
Contributor Author

Hm, that's strange. I get this error on the first line where restrict is used:

ggml.h(889): error C2146: syntax error: missing ')' before identifier 'x'

I checked this on one computer with VS2017 and on another with VS2019

@slaren
Copy link
Member

slaren commented Apr 29, 2023

I am not sure in what version this was added, but MSVC does support restrict with /std:c11.

@grahameth
Copy link
Contributor Author

Well, I updated my MSVC 2017 and also updated the language standard in the project settings, but I still get the same error. But if I'm the only one with this issue I guess you can close it.

@grencez
Copy link
Contributor

grencez commented May 1, 2023

@grahameth are you using CMake? If so, check the compile_commands.json file in the build directory to find the exact build command. Maybe it's not compiling ggml.c as C11 (or newer). C++ or older C versions won't recognize the keyword.

@Green-Sky
Copy link
Collaborator

afaik MS was very (very) slow to add c11 features to their compiler, so might just be a miss.
nvm, it's a c99 feature.

    C99 standard (ISO/IEC 9899:1999): 

        6.7.3.1 Formal definition of restrict (p: 110-112) 

@grahameth
Copy link
Contributor Author

@grencez I don't find a generated file named "compile_commands.json" anywhere.

But anyway, I just set up a VM with a fresh install of VS2022 and cmake and there it indeed works. I still don't understand why it doesn't work on my machines, but it's not worth the time to investigate this.

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.

4 participants