0
I'm currently working on an Objective-C project on Windows that doesn't use any framework. I compile my project using GCC which happens to have Objective-C support under MSYS2 and MinGW64. After hearing about the Language Server Protocol and clangd, I immediately wanted to try it so I downloaded clangd (only available as a standalone install, not available inside MinGW64 itself which makes compatibility with my already-existing tools a bit more difficult) and connected it Visual Studio Code with the vscode-clangd extension.
I found out that the regular LLVM installation, since it's not related to MinGW at all, could not find any headers or libraries which resulted in a lot of errors in the editor. I tried to compile my program in clang instead of GCC, but that only resulted in missing library and header errors since compiling Objective-C is not supported on Windows through clang through either MinGW or the standalone LLVM installation.
As a result, I tried to cheat clangd into thinking it was compiling correctly so that I could still use it by forcing it to use GCC header files. I set up a compiler_commands.json
file in the directory of my project with the following format:
[
{
"directory": "C:/Users/dylanweber/Documents/Objective-C Programming/Objective-C Test",
"command": "C:/Program Files/LLVM/bin/clang -nostdinc -I \"C:/Users/dylanweber/Documents/Objective-C Programming/Objective-C Test\" -isystem \"C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/\" -isystem \"C:/msys64/mingw64/include/\" -isystem \"C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include-fixed/\" -isystem \"C:/msys64/mingw64/x86_64-w64-mingw32/include\" -Wall main.m -lobjc",
"file": "main.m"
}
]
Despite the fact that I only told clangd to interpret main.m, it shows correct syntax comprehension across all the files in the project. Is there anything I'm missing? Is this setup too complicated? Will I run into problems later?
P.S. I can't include clangd
as a tag but I think as the Language Server Protocol grows in popularity, this tag should be added.