Precompiled Header Does Not Work With Code Highlighting

已回答

I am using the latest Clion 2020.2, on Ubuntu 20.04. I have a simple project with a precompiled header that consists of <string>, <iostream>, and <sstream>. However, in all of my source files that use std::string or std::stringstream, Clion reports that 'std' is an undeclared identifier.

No matter what I do, it says that std is undeclared. I thought Clion was supposed to handle this, but do I need to include the pch manually?

 

EDIT: Here is the "commandLine" output from "clionReparse"

0

Hello!

What toolchain do you use? Please attach a screenshot of `File | Settings | Build, Execution, Deployment | Toolchains` (please capture the screenshot after the compiler detection is completed).

0
Avatar
Permanently deleted user

0
Avatar
Permanently deleted user

I've created a minimal example showcasing the problem. I don't know if this is the intended behavior, but precompiled headers are not included .h files without associated .cpp files.

Here is the project structure:

Here is the CMakeLists.txt:

Here is the HeaderOnly.h file :

You can see that Clion doesn't know that std::string is in the precompiled header.

Here is main.cpp where Clion DOES know that string is in the pch:

Is this the intended behavior? And if it is, how would I use a pch in header only files (of which, we have many in our project)?

0

Thank you for the detailed description!

I've created https://youtrack.jetbrains.com/issue/CPP-21872. Please comment or upvote the issue in order to get updates. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.

0

请先登录再写评论。