Skip to content

Add #ifdef __cplusplus extern "C" to all .h to enable calling from C++ #3488

@adritium

Description

@adritium

If you want to call any mp* function from C++, you have to tell the C++ compiler to use C-naming convention (i.e. no name mangling).

This would require adding the following to all micropython header files

#ifdef __cplusplus
extern "C" {
#endif

// mp function declarations

#ifdef __cplusplus
}
#endif

Since calling from C++ is a common enough workflow, I recommend we implement and merge this into master branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions