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

Clangd (Language Server) throws error for __integer_pack at pack.hpp #6412

Closed
andreichalapco opened this issue Jan 11, 2024 · 7 comments · Fixed by #6479
Closed

Clangd (Language Server) throws error for __integer_pack at pack.hpp #6412

andreichalapco opened this issue Jan 11, 2024 · 7 comments · Fixed by #6479

Comments

@andreichalapco
Copy link

I've built the hpx from source (using master from Jun 2023) using a gcc 13.1.1 compiler. My Ide for development is sometimes clion and also nvim that both use clangd language server.

When going trough examples from the hpx I instantly get errors from the language server: Use of undeclared identifier __integer_pack in pack.hpp:49. I know this is a placeholder for the gcc compiler but when running this with clangd it is pretty nerving sometimes...

Should pack.hpp use something in the direction of this:

#if __has_builtin(__make_integer_seq)
      template<typename, size_t... _Indices>
	using _IdxTuple = _Index_tuple<_Indices...>;

      // Clang defines __make_integer_seq for this purpose.
      using __type = __make_integer_seq<_IdxTuple, size_t, _Num>;
#else
      // For GCC and other compilers, use __integer_pack instead.
      using __type = _Index_tuple<__integer_pack(_Num)...>;
#endif

(this is basically taken from this)

In order to reproduce this just run:

clangd --check=main.cpp

Where main.cpp include

#include <hpx/hpx_main.hpp>
#include <hpx/iostream.hpp>

int main()
{
    // Say hello to the world!
    hpx::cout << "Hello World!\n" << std::flush;
    return 0;
}

One other option I tried was using clangd with --query-driver to query the gcc driver for the necessary system headers but this didn't fix the problem.

Is there any solution to make the language server work with the source code of hpx ... ?

I'm not sure if clangd language server is a high priority now ... but I thought I mention this. If needed I could try to make a pull request.

@andreichalapco
Copy link
Author

On further checking the cmake building process I discovered this:

  # Check the availability of certain C++ builtins
  hpx_check_for_builtin_integer_pack(DEFINITIONS HPX_HAVE_BUILTIN_INTEGER_PACK)

  hpx_check_for_builtin_make_integer_seq(
    DEFINITIONS HPX_HAVE_BUILTIN_MAKE_INTEGER_SEQ
  )

So basically if building the source with clang ... I can avoid the macro HPX_HAVE_BUILTIN_INTEGER_PACK ... and have HPX_HAVE_BUILTIN_MAKE_INTEGER_SEQ.

I still believe this is not something good ... because there are for sure many people that want to compile everything with gcc but still use the clangd language server ... (so basically use clion)

@hkaiser
Copy link
Member

hkaiser commented Jan 11, 2024

I'm not sure if anybody I know uses clangd for their work, so I wouldn't know whom to ask. This is probably caused by HPX being configured by one compiler (gcc) and being used with another one (clangd). The decision of what is supported is being made at configuration time, so that later on clangd sees things to be used that it doesn't support.

I'd very much appreciate it if you had the time and interest to come up with a possible fix (PR) for this.

@John98Zakaria
Copy link
Contributor

I had reported that issue to jetbrains years ago.
https://youtrack.jetbrains.com/issue/CPP-29030/False-positive-systax-error-highlighting-for-hpx

@andreichalapco
Copy link
Author

So the issue is related to clangd (clion also uses this language server). I posted an issue and it was fixed in the newer versions of clang.
see clangd/clangd#1906.

@hkaiser
Copy link
Member

hkaiser commented May 2, 2024

Let's not close this issue. We've had similar reports in other contexts. I believe this can be fixed.

@hkaiser hkaiser reopened this May 2, 2024
@andreichalapco
Copy link
Author

Yeah! I think you're right! As a feedback after using hpx there a lot of problems with the clangd lanaguge server, which is a real pity, because I think it is nowadays the most used one (it' s also open source). It would be nice if some efforts would be directed in this direction.

@hkaiser
Copy link
Member

hkaiser commented May 2, 2024

Yeah! I think you're right! As a feedback after using hpx there a lot of problems with the clangd lanaguge server, which is a real pity, because I think it is nowadays the most used one (it' s also open source). It would be nice if some efforts would be directed in this direction.

What other problems are there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants