From ac6bd46d5c30f4e643120aeef1ccd531801a2181 Mon Sep 17 00:00:00 2001 From: Anthony Baxter Date: Thu, 13 Apr 2006 02:06:09 +0000 Subject: spread the extern "C" { } magic pixie dust around. Python itself builds now using a C++ compiler. Still lots and lots of errors in the modules built by setup.py, and a bunch of warnings from g++ in the core. --- Modules/getpath.c | 11 +++++++++++ Modules/main.c | 9 +++++++++ Modules/posixmodule.c | 9 +++++++++ Objects/fileobject.c | 9 +++++++++ Objects/object.c | 9 +++++++++ Objects/unicodeobject.c | 10 ++++++++++ Python/errors.c | 10 ++++++++++ Python/getmtime.c | 9 +++++++++ Python/getopt.c | 9 +++++++++ Python/import.c | 7 +++++++ Python/pystate.c | 11 +++++++++++ Python/pythonrun.c | 9 +++++++++ 12 files changed, 112 insertions(+) diff --git a/Modules/getpath.c b/Modules/getpath.c index 40c3692..8eba730 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -91,6 +91,11 @@ * process to find the installed Python tree. */ +#ifdef __cplusplus + extern "C" { +#endif + + #ifndef VERSION #if defined(__VMS) #define VERSION "2_1" @@ -681,3 +686,9 @@ Py_GetProgramFullPath(void) calculate_path(); return progpath; } + + +#ifdef __cplusplus +} +#endif + diff --git a/Modules/main.c b/Modules/main.c index ceb5bed..28d3294 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -29,6 +29,10 @@ "Type \"help\", \"copyright\", \"credits\" or \"license\" " \ "for more information." +#ifdef __cplusplus +extern "C" { +#endif + /* For Py_GetArgcArgv(); set by main() */ static char **orig_argv; static int orig_argc; @@ -540,3 +544,8 @@ Py_GetArgcArgv(int *argc, char ***argv) *argc = orig_argc; *argv = orig_argv; } + +#ifdef __cplusplus +} +#endif + diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 4cd220e..e07021a 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -22,6 +22,10 @@ # include #endif /* defined(__VMS) */ +#ifdef __cplusplus +extern "C" { +#endif + PyDoc_STRVAR(posix__doc__, "This module provides access to operating system functionality that is\n\ standardized by the C Standard and the POSIX standard (a thinly\n\ @@ -8253,3 +8257,8 @@ INITFUNC(void) PyModule_AddObject(m, "statvfs_result", (PyObject*) &StatVFSResultType); } + +#ifdef __cplusplus +} +#endif + diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 20e71a3..185caa4 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -48,6 +48,10 @@ #define NEWLINE_LF 2 /* \n newline seen */ #define NEWLINE_CRLF 4 /* \r\n newline seen */ +#ifdef __cplusplus +extern "C" { +#endif + FILE * PyFile_AsFile(PyObject *f) { @@ -2441,3 +2445,8 @@ Py_UniversalNewlineFread(char *buf, size_t n, f->f_skipnextlf = skipnextlf; return dst - buf; } + +#ifdef __cplusplus +} +#endif + diff --git a/Objects/object.c b/Objects/object.c index 0ce4332..d3dda1b 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -3,6 +3,10 @@ #include "Python.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifdef Py_REF_DEBUG Py_ssize_t _Py_RefTotal; @@ -2112,3 +2116,8 @@ _PyTrash_destroy_chain(void) --_PyTrash_delete_nesting; } } + +#ifdef __cplusplus +} +#endif + diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 1e0db15..30ae6f0 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -83,6 +83,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifdef __cplusplus +extern "C" { +#endif + /* Free list for Unicode objects */ static PyUnicodeObject *unicode_freelist; static int unicode_freelist_size; @@ -7418,6 +7423,11 @@ _PyUnicode_Fini(void) unicode_freelist_size = 0; } +#ifdef __cplusplus +} +#endif + + /* Local variables: c-basic-offset: 4 diff --git a/Python/errors.c b/Python/errors.c index 7fc4c97..25deaa6 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -16,6 +16,11 @@ extern char *strerror(int); #include +#ifdef __cplusplus +extern "C" { +#endif + + void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback) { @@ -786,3 +791,8 @@ PyErr_ProgramText(const char *filename, int lineno) } return NULL; } + +#ifdef __cplusplus +} +#endif + diff --git a/Python/getmtime.c b/Python/getmtime.c index f0ac899..54edb53 100644 --- a/Python/getmtime.c +++ b/Python/getmtime.c @@ -6,6 +6,10 @@ #include "Python.h" #include "pyconfig.h" +#ifdef __cplusplus +extern "C" { +#endif + time_t PyOS_GetLastModificationTime(char *path, FILE *fp) { @@ -15,3 +19,8 @@ PyOS_GetLastModificationTime(char *path, FILE *fp) else return st.st_mtime; } + +#ifdef __cplusplus +} +#endif + diff --git a/Python/getopt.c b/Python/getopt.c index d80f607..5429fac5 100644 --- a/Python/getopt.c +++ b/Python/getopt.c @@ -27,6 +27,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + int _PyOS_opterr = 1; /* generate error messages */ int _PyOS_optind = 1; /* index into argv array */ char *_PyOS_optarg = NULL; /* optional argument */ @@ -81,3 +85,8 @@ int _PyOS_GetOpt(int argc, char **argv, char *optstring) return option; } + +#ifdef __cplusplus +} +#endif + diff --git a/Python/import.c b/Python/import.c index c3bd275..81027d8 100644 --- a/Python/import.c +++ b/Python/import.c @@ -17,6 +17,9 @@ #ifdef HAVE_FCNTL_H #include #endif +#ifdef __cplusplus +extern "C" { +#endif extern time_t PyOS_GetLastModificationTime(char *, FILE *); /* In getmtime.c */ @@ -2947,3 +2950,7 @@ PyImport_AppendInittab(char *name, void (*initfunc)(void)) return PyImport_ExtendInittab(newtab); } + +#ifdef __cplusplus +} +#endif diff --git a/Python/pystate.c b/Python/pystate.c index ca19b76..9c85b5c 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -37,6 +37,10 @@ static PyThread_type_lock head_mutex = NULL; /* Protects interp->tstate_head */ #define HEAD_LOCK() PyThread_acquire_lock(head_mutex, WAIT_LOCK) #define HEAD_UNLOCK() PyThread_release_lock(head_mutex) +#ifdef __cplusplus +extern "C" { +#endif + /* The single PyInterpreterState used by this process' GILState implementation */ @@ -552,4 +556,11 @@ PyGILState_Release(PyGILState_STATE oldstate) else if (oldstate == PyGILState_UNLOCKED) PyEval_SaveThread(); } + +#ifdef __cplusplus +} +#endif + #endif /* WITH_THREAD */ + + diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 818c760..b98d6fb 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -37,6 +37,10 @@ _Py_GetRefTotal()) #endif +#ifdef __cplusplus +extern "C" { +#endif + extern char *Py_GetPath(void); extern grammar _PyParser_Grammar; /* From graminit.c */ @@ -1692,3 +1696,8 @@ PyParser_SimpleParseString(const char *str, int start) { return PyParser_SimpleParseStringFlags(str, start, 0); } + +#ifdef __cplusplus +} +#endif + -- cgit v0.12