Author Topic: Can't find declaration for std::to_string() and std::stoi()  (Read 7256 times)

Offline Pacfrog

  • Single posting newcomer
  • *
  • Posts: 2
Can't find declaration for std::to_string() and std::stoi()
« on: April 14, 2025, 04:40:03 pm »
Hello, I'm using Code::Blocks on Debian 12, with the following version info: Version: 20.03+svn13046-0.1+b2.I have noticed that when I write standard C++ code using std::to_string() or std::stoi(), the code compiles and runs perfectly, but when I right-click and choose "Find declaration", Codeblocks shows:

Warning: Not found "to_string"
Warning: Not found "stoi"

Here's my sample code
Code
#include <iostream>
#include <string>

using namespace std;

int main() {
  string str = to_string(123); // Double-click 'to_string' then right-click Find declaration of: 'to_string'
  int i = stoi("123");         // also here
  return 0;
}


Things I've tried:
1. Verified string header is present.
2. Tries the same setup on Windows with Codeblocks, and the exact same problem happens.

Thanks in advance for your help!
This is my first time posting here, so please kindly guide me if I missed anything.
« Last Edit: April 14, 2025, 04:51:11 pm by Pacfrog »

Offline Vigor

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: Can't find declaration for std::to_string() and std::stoi()
« Reply #1 on: Yesterday at 10:35:17 pm »
I think you can only use "find declaration" functionality to see the declarations of functions you defined.   You are effectively trying to ask codeblocks to show you code it doesn't have because they are found in standard libraries.

Offline blauzahn

  • Almost regular
  • **
  • Posts: 198
Re: Can't find declaration for std::to_string() and std::stoi()
« Reply #2 on: Today at 06:09:49 am »
Code::Blocks 20.03 is relatively old. Do you have its codecompletion plugin activated? The current version has a plugin that uses clangd but
it is still a bit unstable.

For standard functions it may be better to refer to cppreference.com instead of the definition found in stdlibc++ or libc++. You can call the website via the help-plugin. Its settings can be found in Settings | Environment | Help Files.