News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Can't find declaration for std::to_string() and std::stoi()

Started by Pacfrog, April 14, 2025, 04:40:03 PM

Previous topic - Next topic

Pacfrog

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

#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.

Vigor

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.

blauzahn

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.