From 6c1874fc2bd0e0d2e30de78fe1f1fe8bcf8a20be Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 10 Jan 1995 17:43:33 +0000 Subject: [PATCH] changes for C++ (Tim MacKenzie) --- Include/mymalloc.h | 14 +++++++++----- Modules/Makefile.pre.in | 5 +++-- Modules/config.c.in | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Include/mymalloc.h b/Include/mymalloc.h index 877bcb98971..3c80db10f62 100644 --- a/Include/mymalloc.h +++ b/Include/mymalloc.h @@ -1,9 +1,5 @@ #ifndef Py_MYMALLOC_H #define Py_MYMALLOC_H -#ifdef __cplusplus -extern "C" { -#endif - /*********************************************************** Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The Netherlands. @@ -52,7 +48,15 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifdef HAVE_STDLIB_H #include -#else /* !HAVE_STDLIB */ +#endif + +#ifdef __cplusplus +// Move this down here since some C++ #include's don't like to be included +// inside an extern "C" +extern "C" { +#endif + +#ifndef HAVE_STDLIB_H extern ANY *malloc PROTO((size_t)); extern ANY *calloc PROTO((size_t, size_t)); extern ANY *realloc PROTO((ANY *, size_t)); diff --git a/Modules/Makefile.pre.in b/Modules/Makefile.pre.in index 5662ea5aa62..8ebf62a03d1 100644 --- a/Modules/Makefile.pre.in +++ b/Modules/Makefile.pre.in @@ -6,6 +6,7 @@ # brought up to date by running "make Makefile". (The makesetup also # creates config.c from config.c.in in the source directory.) +LINKCC = $(CC) # === Variables set by makesetup === MODOBJS= _MODOBJS_ @@ -79,12 +80,12 @@ $(LIB): $(OBJS) Makefile $(RANLIB) $(LIB) ../python: config.o $(MYLIBS) Makefile - $(CC) $(OPT) config.o $(LINKFORSHARED) \ + $(LINKCC) $(OPT) config.o $(LINKFORSHARED) \ $(MYLIBS) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python mv python ../python config.o: config.c Makefile $(MYLIBS) - $(CC) $(CFLAGS) -DPYTHONPATH=\"$(PYTHONPATH)\" -c config.c + $(LINKCC) $(CFLAGS) -DPYTHONPATH=\"$(PYTHONPATH)\" -c config.c clean: -rm -f *.o python core *~ [@,#]* *.old *.orig *.rej diff --git a/Modules/config.c.in b/Modules/config.c.in index ba8b9d78a5e..0c2f114489d 100644 --- a/Modules/config.c.in +++ b/Modules/config.c.in @@ -41,6 +41,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "osdefs.h" #include "intrcheck.h" +#if defined(__cplusplus) +extern "C" { +#endif #ifndef NO_MAIN @@ -59,9 +62,14 @@ static char *argv0; static char **orig_argv; static int orig_argc; +#if defined(__cplusplus) +int realmain(int, char**); +main(int argc, char **argv) +#else main(argc, argv) int argc; char **argv; +#endif { orig_argc = argc; orig_argv = argv; @@ -76,9 +84,13 @@ getprogramname() } void +#if defined(__cplusplus) +getargcargv(int *argc, char ***argv) +#else getargcargv(argc,argv) int *argc; char ***argv; +#endif { *argc = orig_argc; *argv = orig_argv; @@ -144,11 +156,16 @@ getcopyright() #define PYTHONPATH ".:/usr/local/lib/python" #endif /* !PYTHONPATH */ +#ifndef __cplusplus extern char *getenv(); +#endif char * getpythonpath() { +#ifdef __cplusplus + void fatal(char *); +#endif char *path = getenv("PYTHONPATH"); char *defpath = PYTHONPATH; static char *buf = NULL; @@ -215,3 +232,7 @@ struct frozen { {0, 0, 0} }; #endif + +#if defined(__cplusplus) +} +#endif