use of __cplusplus in python source

At the top of each C header file (after the include guards), use this
#ifdef __cplusplus
extern "C" {

and at the bottom, need to enclose

#ifdef __cplusplus

This if loop tutorial will help:
Last edited on
It means that the extern symbols are in C format and not C++ format. ie the names are not mangled to include their type. This also means that overloaded functions can't be used. This means that the function parameters can only use C types (no std::string etc). This way the same library can be used by both C and C++ programs.

What is the use of following in the header files in python source
I don't think that this appears in phyton code.

Does it means Python provides us to build code using C++ compiler.
Python is a language. Compiler is something different. It migth be possible to build a toolchain that compiles both.

However you can combine the two languages. See:

For python compilers see:
CPython (by far, the most widely used implementation of Python) is written in C (and Python).

Source code:
There is no C++ in the Python source.

github reports:
Python 62.6%
C 35.3%
C++ 0.7%
The dirty sh!t dale14886 edited their post with spam.
Topic archived. No new replies allowed.