boocs / unreal-clangd

VSCode extension for Unreal and clangd
61 stars 5 forks source link

Encountered some errors similar to #4 on Mac m1 #8

Closed ColinWttt closed 11 months ago

ColinWttt commented 11 months ago

Followed the readme.md and intellisense works really good and fast, development build can open editor successfully. Encounters several errors similar to #4,

project: Unreal example project Lyra hardware: Mac M1 pro (arm64) macOS: 14.1.2 Xcode: 15.0.1 clangd: 16.0.6 (also configured in clangd-vscode path) Unreal: 5.3.2 VS code: 1.84.2 (Universal)

  1. type specifier is required for all declarationsclang(missing_type_specifier) on GENERATED_BODY macro
  2. .generated.h' file not foundclang(pp_file_not_found)
  3. Type 'Super' (aka 'UObject') is not a direct or virtual base of 'ULyraGameplayAbility_Death'clang(not_direct_base_or_virtual)
  4. Cannot initialize object parameter of type 'UAbilitySystemComponent' with an expression of type 'ULyraAbilitySystemComponent'clang(member_function_call_bad_type)
  5. No member named 'ActivateAbility' in 'UObject'; did you mean simply 'ActivateAbility'? (fix available)clang(no_member_suggest) lyraGameplayAbility_Death.cpp(32, 34): 'ActivateAbility' declared here

These type of error appera at every .cpp/.h file in the environment.

boocs commented 11 months ago

First make sure you've built your project first. The .generated.h file not found message seems to indicate it hasn't been Built.

Make sure you use the 'Editor' suffix along with the development flag to build.

In Terminal->Run Build Task... run this: image

Of course yours won't have Win64.

Also make sure you run my extensions command: image

Errors might occur after you build and this command should fix them.

Of course you still might get errors. Let me know!

ColinWttt commented 11 months ago

I tried various methods and don't remember the specific order anymore. Run Build Task, updated the compile command, create unreal-clangd project in full mode, set UEIntellisense Fixes › Compiler: Intellisense Mode to clang-arm64, checked enable UEIntellisense Fixes: Enable Fixes , and set UEIntellisense Fixes › Compiler: Intellisense Mode to arm64.

I'm not sure which of these steps are necessary, but it did work, and the results are excellent.

Pasted image 20231205114649 Pasted image 20231205114717 Pasted image 20231205114746 Pasted image 20231205114803
boocs commented 11 months ago

Strange, ueintellisense fixes shouldn't have done anything. It's for Microsoft's C++ extension and shouldn't do anything to get clangd to work. You should be able to disable the ueintellisense fixes extension.

I'm wondering if you somehow got Microsoft's C++ extension to do the intellisense. That could have happened if you reset your project. It would have overwrote the cfg files for your project so it defaulted back to Microsoft's C++ extension.

You can test this out by using my extension's command Create Unreal clangd project and choosing Partial install.

It should add these settings, to your project's settings.json, that disables Microsoft's C++ extension's ability to do Intellisense.

"C_Cpp.autocomplete": "disabled",
"C_Cpp.errorSquiggles": "disabled",
"C_Cpp.formatting": "disabled",
"C_Cpp.intelliSenseEngine": "disabled",

I still keep Microsoft's C++ extension enabled for debugging.



I do have some other stuff to try if you are accidently using Microsoft's C++ extension and want to try to get clangd to work. If I'm wrong and you are really using clangd then great!

ColinWttt commented 11 months ago

Background: Microsoft C++ plugin is disabled. I attempted to replicate the process using partial mode:

  1. In Unreal Editor, clicked on Refresh Visual Studio Code.
  2. After opening VS Code, received a prompt to open Completion Helper.cpp.
  3. As expected, intellisense became ineffective.
  4. Ran Create Unreal clangd project and chose Partial installation.
  5. Syntax suggestions became effective again. The current setting.json is as follows:
{
    "unreal-clangd.creation.overwrite": "partial",
    "unreal-clangd.utility.createProjectOnStartup": false,
    "editor.suggest.snippetsPreventQuickSuggestions": false
}
  1. No CPP-related options appeared, so I manually added them. However, these (darker) CPP setting code seems did not take effect. Pasted image 20231205163428
  2. Code intelligence suggestions remained effective.

I believe this plugin is indeed effective on macOS ARM64. After sufficient polishing, I strongly recommend that you apply for Epic's MegaGrants.

boocs commented 11 months ago

Cool, didn't think it worked with the default settings for Mac. Thanks for testing it out!

Just to be sure, did you have to use any of these unreal-clangd extension settings below?


Yeah, those Microsoft C++ extensions settings, in settings.json, will not get set if you have Microsoft's C++ extensions disabled when installing a clangd project. This is because a VSCode exception is thrown when setting the settings of an extension that is disabled.

I should ask users to set them, though, if you do enable MS's C++ extension afterward... Like previously mentioned, MS C++ extension is still useful for it's debugging and shouldn't interfere with clangd with those settings set.


I wouldn't think my projects would be considered. This one has very limited number of users. There's also lots of competition for Unreal IDEs.

Visual Studio 2022 is suppose to be a lot better and they're also doing updates specific for Unreal.

People say Rider is really good for Unreal even though it's paid. Some reddit users mentioned you can legally use it for free if you use the nightly builds though I've never tried it.

ColinWttt commented 11 months ago

Just to be sure, did you have to use any of these unreal-clangd extension settings below?

Architecture Platform Compiler Path

Architecture was set to arm64, and both Platform and Compiler Path were blank. After I set Architecture to blank, using partial build, Intellisense still works fine.

Visual Studio 2022 requires intricate setup, installing plugins from Visual Studio and Unreal, and the startup speed is still quite slow.

boocs commented 11 months ago

The Architecture setting is used when the Update Compile Commands setting is run. You don't usually run this manually. The extension should detect when it needs to run.

You should run it manually, though, now that Architecture is blank and restart VSCode to see if it still works without errors.

Would be helpful so I can update my Docs for Mac arm64 users and let them know your results on if they need that setting or not.


I'm getting a few winks so won't be responding till I wake up. I also have stuff to do so can't respond for awhile after that as well.

ColinWttt commented 11 months ago

You should run it manually, though, now that Architecture is blank and restart VSCode to see if it still works without errors.

Looks good, nothing really change. Thanks for your help!