diff --git a/sourcepawn/compiler/AMBuilder b/sourcepawn/compiler/AMBuilder index 249d419c..9ec19520 100644 --- a/sourcepawn/compiler/AMBuilder +++ b/sourcepawn/compiler/AMBuilder @@ -79,7 +79,7 @@ elif builder.target_platform == 'mac': binary.sources += [ 'libpawnc.cpp', - 'lstring.c', + 'lstring.cpp', 'memfile.cpp', 'pawncc.cpp', 'sc1.c', @@ -91,7 +91,7 @@ binary.sources += [ 'sc7.c', 'scexpand.c', 'sci18n.c', - 'sclist.c', + 'sclist.cpp', 'scmemfil.cpp', 'scstate.cpp', 'sctracker.c', diff --git a/sourcepawn/compiler/lstring.c b/sourcepawn/compiler/lstring.cpp similarity index 95% rename from sourcepawn/compiler/lstring.c rename to sourcepawn/compiler/lstring.cpp index f5156b32..102a956e 100644 --- a/sourcepawn/compiler/lstring.c +++ b/sourcepawn/compiler/lstring.cpp @@ -37,7 +37,7 @@ * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */ -size_t +extern "C" size_t strlcpy(char *dst, const char *src, size_t siz) { char *d = dst; @@ -93,7 +93,7 @@ strlcpy(char *dst, const char *src, size_t siz) * Returns strlen(src) + MIN(siz, strlen(initial dst)). * If retval >= siz, truncation occurred. */ -size_t +extern "C" size_t strlcat(char *dst, const char *src, size_t siz) { char *d = dst; diff --git a/sourcepawn/compiler/lstring.h b/sourcepawn/compiler/lstring.h index ca62cb9a..f8206e11 100644 --- a/sourcepawn/compiler/lstring.h +++ b/sourcepawn/compiler/lstring.h @@ -9,10 +9,18 @@ #if !defined HAVE_SAFESTR -size_t +#if defined(__cplusplus) +# define EXPORT extern "C" +#else +# define EXPORT +#endif + +EXPORT size_t strlcpy(char *dst, const char *src, size_t siz); -size_t +EXPORT size_t strlcat(char *dst, const char *src, size_t siz); +#undef EXPORT + #endif diff --git a/sourcepawn/compiler/sclist.c b/sourcepawn/compiler/sclist.cpp similarity index 95% rename from sourcepawn/compiler/sclist.c rename to sourcepawn/compiler/sclist.cpp index 8ffd9c73..6813b936 100644 --- a/sourcepawn/compiler/sclist.c +++ b/sourcepawn/compiler/sclist.cpp @@ -319,12 +319,13 @@ SC_FUNC stringpair *find_subst(char *name,int length) if (item && (item->flags & flgDEPRECATED) != 0) { static char macro[128]; - char *rem, *msg = (item->documentation != NULL) ? item->documentation : ""; + const char *msg = (item->documentation != NULL) ? item->documentation : ""; strlcpy(macro, item->first, sizeof(macro)); /* If macro contains an opening parentheses and a percent sign, then assume that * it takes arguments and remove them from the warning message. */ + char *rem; if ((rem = strchr(macro, '(')) != NULL && strchr(macro, '%') > rem) { *rem = '\0';