Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewing CPython Code in CLion

Tags:

c

cpython

clion

Sorry for a question that might appear stupid to more experienced developers: I am still a newcomer to C and C++.

I come from Python/Java development land and am trying to get a better insight into C and C++. I installed JetBrains CLion and cloned CPython mercurial repository. However when I started looking at the source code, I realized that Clion was highlighting a lot of constructs that seemed to be working. For instance: enter image description here

Or

enter image description here

As far as I can see, Clion seems the have problem with the identation style of Python, C code, but once again, I might be wrong.

How Clion configurations can be altered for it to properly parse the CPython code?

like image 941
chiffa Avatar asked Jul 19 '26 05:07

chiffa


1 Answers

CPython uses GNU Autotools for the build, but that toolset is not supported by CLion. See issues CPP-494 and CPP-193. CLion currently supports only one build system - CMake.

You can create your own CMakeLists.txt file and list the sources in there. This will help CLion to understand the structure of the source tree and allow it to find the headers etc:

cmake_minimum_required(VERSION 3.0)
project(cpython)

file(GLOB SOURCE_FILES
    Python/*.c
    Parser/*.c
    Objects/*.c
    Modules/*.c)

include_directories(Include)

add_executable(cpython ${SOURCE_FILES})

For the actual build, use standard build tools from command line. Alternatively, custom command can be added to CMakeLists.txt to call make. See add_custom_command for that.

like image 156
rbrich Avatar answered Jul 20 '26 22:07

rbrich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!