summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMaximilien Colange <111890372+EpigeneMax@users.noreply.github.com>2022-11-08 22:30:07 +0100
committerGitHub <noreply@github.com>2022-11-08 21:30:07 +0000
commit2d40828375f2a25a4b931e582bf0ad5161926e42 (patch)
treea185b8ab1fa6df1dbc764049dff77458fd4e449e /docs
parente14f241cecf5d37b29a057b93779737f81c5a68f (diff)
downloadcython-2d40828375f2a25a4b931e582bf0ad5161926e42.tar.gz
Fix linkage for `cdef public` functions in C++ mode (#5040)
Fixes #1839 cdef public functions should be declared with the appropriate linkage: * in C mode, either extern or extern "C", depending on whether the header file is included in (resp. object code is linked against) a C or a C++ compilation unit. Choice is made at compile-time through #ifdef __cplusplus macros. NB: This is the current behavior. * in C++ mode, extern "C++" is the only option, as C code cannot call C++ code. Note that extern "C++" should be preferred over extern to allow users to #include the C++ header inside a extern "C" block (which is legal, although barely used). Note that the current behavior is OK for C mode, but is incorrect for the C++ mode. As described in #1839, this incorrect behavior is diagnosed by compilers emitting warnings when cdef public functions return a C++ type (e.g. std::vector). The test introduced in this PR checks that the current behavior for C mode (with both C and C++ compatibility) is preserved, and that the behavior for C++ mode is fixed.
Diffstat (limited to 'docs')
-rw-r--r--docs/examples/tutorial/embedding/embedded.pyx1
1 files changed, 1 insertions, 0 deletions
diff --git a/docs/examples/tutorial/embedding/embedded.pyx b/docs/examples/tutorial/embedding/embedded.pyx
index 719702c75..2ed823945 100644
--- a/docs/examples/tutorial/embedding/embedded.pyx
+++ b/docs/examples/tutorial/embedding/embedded.pyx
@@ -3,6 +3,7 @@
# The following two lines are for test purposes only, please ignore them.
# distutils: sources = embedded_main.c
# tag: py3only
+# tag: no-cpp
TEXT_TO_SAY = 'Hello from Python!'