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

Type std:: and other libiraries cannot be resolved #905

Open
ENate opened this issue Sep 19, 2024 · 8 comments
Open

Type std:: and other libiraries cannot be resolved #905

ENate opened this issue Sep 19, 2024 · 8 comments

Comments

@ENate
Copy link

ENate commented Sep 19, 2024

Describe the bug
I am unable to access std::cout, std::string and similar C** libraries on Eclipse. When I open or create a new CMake (Makefile) project on eclipse C++, may of these libraries are not detected. I usually see the following error:

Description
Type 'std::error_code' could not be resolved	
Type std

To Reproduce
Steps to reproduce the behavior:

  1. Create or open a C** project
  2. Add or use one of the std libs (e.g std::string, etc)'
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.
I will expect that C++ libs and language server can automatically be picked up and code assist work normally.
Screenshots
If applicable, add screenshots to help explain your problem.

Version Information (please complete the following information):

  • OS and OS Version/extra details: Ubuntu (Linux) 22.04 LTS
  • Eclipse Version 2024-09 (4.33.0) (Eclipse C++)
  • CDT Version 11.6.1.202406241230
    Thanks

Additional context
Add any other context about the problem here. For example the error log (in workspace/.metadata/.log) or for GDB interaction issues the GDB traces

@ENate ENate changed the title Type std:: cannot be reolved Type std:: and other libiraries cannot be resolved Sep 24, 2024
@i-garrison
Copy link
Contributor

Do not forget to include required headers, also some important c++20 features are not implemented and you may need to change compiler standard version (like limit to -std=c++17 in built-in compiler settings provider.) Simple std::string code should work fine with c++17 or lower.

@ENate
Copy link
Author

ENate commented Sep 29, 2024

Thanks @i-garrison . I added 17 in my make files etc. Do you think there is need to include -std=c++17to

${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"

under the Eclipse Preferences->Build->Settings->Discovery? I suppose this will be picked up.

@i-garrison
Copy link
Contributor

i-garrison commented Sep 29, 2024

Thanks @i-garrison . I added 17 in my make files etc. Do you think there is need to include -std=c++17to

${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"

under the Eclipse Preferences->Build->Settings->Discovery? I suppose this will be picked up.
You can check value of __cplusplus macro to confirm which C++ standard version you have configured. See Preprocessor includes -> Entries -> CDT GCC Built-in Compiler Settings - may have to reindex project for those to take effect.

@ENate
Copy link
Author

ENate commented Sep 29, 2024

I saw __cpluscplus=201703L under the option you proposed. I only got to see Preprocessor Includes after selecting the project -> New -> ...Add C++ project Nature. Is this okay?

@i-garrison
Copy link
Contributor

I saw __cpluscplus=201703L under the option you proposed. I only got to see Preprocessor Includes after selecting the project -> New -> ...Add C++ project Nature. Is this okay?

Hi @ENate you need to have your c++ project properly configured, so likely yes. Could be easiest to double-check by starting from scratch and selecting e.g. managed c++ build.

@ENate
Copy link
Author

ENate commented Sep 29, 2024

Thanks @i-garrison . So does this __cpluscplus=201703L corresponds to C++ 17?

@i-garrison
Copy link
Contributor

i-garrison commented Sep 29, 2024

Thanks @i-garrison . So does this __cpluscplus=201703L corresponds to C++ 17?

It does, yes. Make sure your source file is recognized as c++ file and all necessary headers are included and resolved (check via indexer -> search for unresolved includes.) IOW it works for me with C++17.

@ENate
Copy link
Author

ENate commented Sep 29, 2024

Thanks indeed. This is my first experience with using Eclipse cdT for c++ development.

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

No branches or pull requests

2 participants