Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 657f85b

Browse files
Add throw specifier for GCC
/usr/include/string.h:43:28: error: declaration of ‘void* memcpy(void*, const void*, size_t) throw ()’ has a different exception specifier size_t __n) __THROW __nonnull ((1, 2));
1 parent 0f324d6 commit 657f85b

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

src/pal/inc/mbusafecrt.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ typedef int errno_t;
3131
// define the return value for success
3232
#define SAFECRT_SUCCESS 0
3333

34+
#if defined(_MSC_VER) || defined(__llvm__)
35+
#define THROW_DECL
36+
#else
37+
#define THROW_DECL throw()
38+
#endif
39+
3440
#ifdef __cplusplus
3541
extern "C" {
3642
#endif
@@ -98,7 +104,7 @@ extern int swscanf_s( const WCHAR *string, const WCHAR *format, ... );
98104
extern int _snscanf_s( const char *string, size_t count, const char *format, ... );
99105
extern int _snwscanf_s( const WCHAR *string, size_t count, const WCHAR *format, ... );
100106

101-
extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count );
107+
extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count ) THROW_DECL;
102108
extern errno_t memmove_s( void * dst, size_t sizeInBytes, const void * src, size_t count );
103109

104110
#ifdef __cplusplus

src/pal/inc/pal.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ typedef void * NATIVE_LIBRARY_HANDLE;
143143
#define LANG_THAI 0x1e
144144

145145
/******************* Compiler-specific glue *******************************/
146+
#if defined(_MSC_VER) || defined(__llvm__)
147+
#define THROW_DECL
148+
#else
149+
#define THROW_DECL throw()
150+
#endif
146151

147152
#ifndef _MSC_VER
148153
#if defined(CORECLR)
@@ -4324,7 +4329,7 @@ PALIMPORT int __cdecl memcmp(const void *, const void *, size_t);
43244329
PALIMPORT void * __cdecl memset(void *, int, size_t);
43254330
PALIMPORT void * __cdecl memmove(void *, const void *, size_t);
43264331
PALIMPORT void * __cdecl memchr(const void *, int, size_t);
4327-
PALIMPORT long long int __cdecl atoll(const char *);
4332+
PALIMPORT long long int __cdecl atoll(const char *) THROW_DECL;
43284333
PALIMPORT size_t __cdecl strlen(const char *);
43294334
PALIMPORT int __cdecl strcmp(const char*, const char *);
43304335
PALIMPORT int __cdecl strncmp(const char*, const char *, size_t);
@@ -4363,7 +4368,7 @@ PALIMPORT int __cdecl toupper(int);
43634368
#define _TRUNCATE ((size_t)-1)
43644369
#endif
43654370

4366-
PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t);
4371+
PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t) THROW_DECL;
43674372
PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
43684373
PALIMPORT char * __cdecl _strlwr(char *);
43694374
PALIMPORT int __cdecl _stricmp(const char *, const char *);
@@ -4503,10 +4508,10 @@ PALIMPORT double __cdecl acos(double);
45034508
PALIMPORT double __cdecl acosh(double);
45044509
PALIMPORT double __cdecl asin(double);
45054510
PALIMPORT double __cdecl asinh(double);
4506-
PALIMPORT double __cdecl atan(double);
4507-
PALIMPORT double __cdecl atanh(double);
4511+
PALIMPORT double __cdecl atan(double) THROW_DECL;
4512+
PALIMPORT double __cdecl atanh(double) THROW_DECL;
45084513
PALIMPORT double __cdecl atan2(double, double);
4509-
PALIMPORT double __cdecl cbrt(double);
4514+
PALIMPORT double __cdecl cbrt(double) THROW_DECL;
45104515
PALIMPORT double __cdecl ceil(double);
45114516
PALIMPORT double __cdecl cos(double);
45124517
PALIMPORT double __cdecl cosh(double);
@@ -4536,10 +4541,10 @@ PALIMPORT float __cdecl acosf(float);
45364541
PALIMPORT float __cdecl acoshf(float);
45374542
PALIMPORT float __cdecl asinf(float);
45384543
PALIMPORT float __cdecl asinhf(float);
4539-
PALIMPORT float __cdecl atanf(float);
4540-
PALIMPORT float __cdecl atanhf(float);
4544+
PALIMPORT float __cdecl atanf(float) THROW_DECL;
4545+
PALIMPORT float __cdecl atanhf(float) THROW_DECL;
45414546
PALIMPORT float __cdecl atan2f(float, float);
4542-
PALIMPORT float __cdecl cbrtf(float);
4547+
PALIMPORT float __cdecl cbrtf(float) THROW_DECL;
45434548
PALIMPORT float __cdecl ceilf(float);
45444549
PALIMPORT float __cdecl cosf(float);
45454550
PALIMPORT float __cdecl coshf(float);

src/pal/src/safecrt/memcpy_s.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ errno_t __cdecl memcpy_s(
5454
size_t sizeInBytes,
5555
const void * src,
5656
size_t count
57-
)
57+
) THROW_DECL
5858
{
5959
if (count == 0)
6060
{

0 commit comments

Comments
 (0)