Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: mayaming on September 26, 2024, 06:55:28 am

Title: can't jump to definition of std::string_view
Post by: mayaming on September 26, 2024, 06:55:28 am
hi,

I'm new to code blocks. I write my first cpp console application but can't jump to declaration or implementation of std::string_view when I right click those menu items. Meanwhile, it works for std::string. Since string_view is supported since c++ 17, I'm wondering if it is because codeblock doesn't support declaration or implementation jumping for those added after c++ 17?

The "-std=c++20" option is checked in compiler settings and it could build and run correctly. My g++ version is:

g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Here's the code:
Code
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s("Hello world!");
    string_view sv(s.c_str(), 5);
    cout <<sv <<endl;
    return 0;
}

Thanks!


 
Title: Re: can't jump to definition of std::string_view
Post by: Miguel Gimenez on September 26, 2024, 03:43:59 pm
The "legacy" Code Completion plugin cannot cope with the complexities of recent C++ standards. The Clangd-plugin should work, but only recent C::B versions incluye it (you did not specify your C::B version).

Look for Clangd in the wiki for more information.
Title: Re: can't jump to definition of std::string_view
Post by: ollydbg on September 26, 2024, 03:49:01 pm
What is your C::B version? Maybe you can try the clangd_client plugin.

Title: Re: can't jump to definition of std::string_view
Post by: mayaming on September 27, 2024, 01:27:40 pm
Thanks Gimenez and ollydbg! Here's my C::B information, Build Sep 14 2024:

Name                   : Code::Blocks
Version                : svn-r13570
SDK Version            : 2.25.0
Scintilla Version      : 3.7.5
Author                 : The Code::Blocks Team
E-mail                 : info@codeblocks.org
Website                : https://www.codeblocks.org
OS                     : Linux 6.8.0-45-generic x86_64
Desktop environment    : GNOME
Scaling factor         : 1.000000
Detected scaling factor: 1.000000
Display PPI            : 96x96
Display count          : 1
Display 0              : XY=[0,0]; Size=[1920,1080]; Primary

wxWidgets Library (wxGTK port)
Version 3.2.2 (Unicode: wchar_t, debug level: 1),
Runtime version of toolkit used is 3.24.
Compile-time GTK+ version is 3.24.36.


I'm using Ubuntu 22.04.5 LTS in a vmware player.

I followed the steps on https://wiki.codeblocks.org/index.php/CB_Clangd_Client (https://wiki.codeblocks.org/index.php/CB_Clangd_Client). I installed clang-16:

Debian clangd version 16.0.6 (15~deb12u1)
Features: linux+grpc
Platform: x86_64-pc-linux-gnu


But I got stuck in this step:

Navigate to Setting->Plugins->Manage Plugins and enable Clangd_client.

I don't have the "Clangd_client" item to enable. Is it a problem of my C::B version?
Title: Re: can't jump to definition of std::string_view
Post by: ollydbg on September 27, 2024, 02:56:19 pm

Navigate to Setting->Plugins->Manage Plugins and enable Clangd_client.

I don't have the "Clangd_client" item to enable. Is it a problem of my C::B version?

Where did you install/download the C::B? Do you build it yourself?

It is very strange that you don't have "Clangd_client" plugin installed.
Title: Re: can't jump to definition of std::string_view
Post by: stahta01 on September 27, 2024, 07:47:56 pm
I am guessing he needs to install "codeblocks-contrib" package.

Tim S.
Title: Re: can't jump to definition of std::string_view
Post by: mayaming on September 29, 2024, 06:26:37 am
Here's how to got C::B installed. I added

deb https://apt.xaviou.fr/debian12/ bookworm main
deb-src https://apt.xaviou.fr/debian12/ bookworm main


to my apt source and then installed codeblocks, but I did not install codeblocks-contrib. After I installed it, the "Clangd_Client" plugin appeared and now I can goto implementation of string_view.

After I jumped to the source code of string_view, it's not correctly highlighted (I attached the screen shot), but anyway I can jump to read the source now. Thanks for your help!


Title: Re: can't jump to definition of std::string_view
Post by: mayaming on September 30, 2024, 03:19:03 am
The highlight issue is because string_view header file doesn't have an extension, so it won't be applied with c/c++ syntax highlight. It worked after I added "*" to c/c++ file pattern matching.