Fixes for C++ Winelib compilation.

diff --git a/include/xmalloc.h b/include/xmalloc.h
index 78c355c..e909cb8 100644
--- a/include/xmalloc.h
+++ b/include/xmalloc.h
@@ -1,9 +1,17 @@
 #ifndef __WINE_XMALLOC_H
 #define __WINE_XMALLOC_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void *xmalloc( int size );
 void *xcalloc( int size );
 void *xrealloc( void *ptr, int size );
 char *xstrdup( const char *str );
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif  /* __WINE_XMALLOC_H */
diff --git a/library/winestub.c b/library/winestub.c
index dd36af4..f5aa038 100644
--- a/library/winestub.c
+++ b/library/winestub.c
@@ -7,7 +7,11 @@
 extern int PASCAL WinMain(HINSTANCE32,HINSTANCE32,LPSTR,int);
 
 /* external declaration here because we don't want to depend on Wine headers */
+#ifdef __cplusplus
+extern "C" HINSTANCE32 MAIN_WinelibInit( int *argc, char *argv[] );
+#else
 extern HINSTANCE32 MAIN_WinelibInit( int *argc, char *argv[] );
+#endif
 
 /* Most Windows C/C++ compilers use something like this to */
 /* access argc and argv globally: */