-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Disable _Atomic
and __thread
keywords on JetBrains IDE only
#134585
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
Comments
Would adding |
Err... I never tried. I'm not on my dev session but I'll try this tomorrow. However, I don't think it helps because even the |
So I tried, and indeed it doesn't help. I think the issue is really with CLion parser and I can only suggest this hacky solution. I'm now used to having red marks but navigating through "next error" is still annoying. |
I'll open a PR to check with buildbots first (still as a PoC) |
Did you report the issue to CLion? I would prefer to fix the issue in CLion rather than having to modify Python. |
It was reported 6 years ago and nothing has changed since then :( |
Ok, turns out there is a workaround that works for me. By using |
Uh oh!
There was an error while loading. Please reload this page.
Note
I already have a PR ready in case this is accepted
This is really a silly issue and it's really not an issue with CPython. The issue is on CLion's side (https://youtrack.jetbrains.com/issue/CPP-15688/False-error-highlighting-for-C11-atomic-functions). The issue has been there for at least the past decade and nothing seemed to advance on JetBrains' side.
Let's assume that I have a file, say
a.h
in which I haveextern _Atomic(size_t) something;
. In another file, I includea.h
and usesize_t i;
. Then CLion complains with "Ambiguous symbolsize_t
". There is one declaration ina.h
and the libc declarationtypedef __SIZE_TYPE__ size_t;
.So anything that is
_Atomic(T)
and usesT
elsewhere while including a file that has_Atomic(T)
somewhere ends up with that kind of issue. For CPython, this would beextern _Atomic(size_t) _mi_numa_node_count;
but there are other occurrences, for instance foruintptr_t
elsewhwere.A similar issue happens with
__thread
. While CLion recognizes the macro, it suggests to includethread.h
to usethread_local
instead and the inspection cannot be disabled.So, now, why would this be actually CPython's responsibility? well.. this is because it really annoys me and hinders me when developing on CLion. Because of
_Atomic
issues, I have syntax errors everywhere and I can't reliably go through real errors.For instance, when I inspect the
mimalloc
bundled files, here's what my IDE would show:Or, even worse, when I just inspect the
_hashopenssl.c
module, I haveConsidering the sheer amount of
size_t
across the code base, this is very disturbing. There is however a simple and very portable solution:__JETBRAINS_IDE__
.The
__JETBRAINS_IDE__
macro is a macro that is set when CLion is parsing code, so never at runtime or whatever (see https://blog.jetbrains.com/clion/2017/02/clion-2017-1-eap-debugger-fixes-ide-macros-and-new-cmake/). Because of this, we can easily do the following inpyport.h
:Fortunately,
_Atomic T
is not used across CPython code base, so we're safe on this side and only_Atomic(T)
is replaced byT
at CLion parse time. It will not affect VSCode or vim users.Note that
sre.c
andsre_lib.h
have vim-only comment:We also have in
bytecode.c
:So it's not unprecedented that we have some editor-only hacks in the project.
cc @colesbury @erlend-aasland @vstinner @serhiy-storchaka
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
_Atomic
and__thread
keywords during CLion parsing phase #134625The text was updated successfully, but these errors were encountered: