Skip to content

Commit dfa66c1

Browse files
committed
Fix the --with-cxx-main build.
1 parent 28a691b commit dfa66c1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Include/Python.h

+6
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,17 @@
120120
#include "pystrcmp.h"
121121
#include "dtoa.h"
122122

123+
#ifdef __cplusplus
124+
extern "C" {
125+
#endif
123126
/* _Py_Mangle is defined in compile.c */
124127
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
125128

126129
/* _Py_char2wchar lives in python.c */
127130
PyAPI_FUNC(wchar_t *) _Py_char2wchar(char *);
131+
#ifdef __cplusplus
132+
}
133+
#endif
128134

129135
/* Convert a possibly signed character to a nonnegative int */
130136
/* XXX This assumes characters are 8 bits wide */

Modules/python.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ _Py_char2wchar(char* arg)
5757
/* Overallocate; as multi-byte characters are in the argument, the
5858
actual output could use less memory. */
5959
argsize = strlen(arg) + 1;
60-
res = PyMem_Malloc(argsize*sizeof(wchar_t));
60+
res = (wchar_t*)PyMem_Malloc(argsize*sizeof(wchar_t));
6161
if (!res) goto oom;
6262
in = (unsigned char*)arg;
6363
out = res;

0 commit comments

Comments
 (0)