diff options
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile.sub | 4 | ||||
-rw-r--r-- | win32/win32.c | 28 |
2 files changed, 27 insertions, 5 deletions
diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 2f200a8424..765951be83 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -188,13 +188,13 @@ LDSHARED = $(LD) -LD XCFLAGS = -DRUBY_EXPORT -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)/missing $(XCFLAGS) !if $(MSC_VER) >= 1400 # Prevents VC++ 2005 (cl ver 14) warnings -DEFS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE +CRTDEFFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE MANIFESTTOOL = mt -nologo LDSHARED_0 = @$(MINIRUBY) -run -e wait_writable -- -n 10 $@ LDSHARED_1 = $(MANIFESTTOOL) -manifest $(@).manifest -outputresource:$(@);2 LDSHARED_2 = @$(RM) $(@:/=\).manifest !endif -CPPFLAGS = $(DEFS) $(ARCHDEFS) $(CPPFLAGS) +CPPFLAGS = $(CRTDEFFLAGS) $(DEFS) $(ARCHDEFS) $(CPPFLAGS) DLDFLAGS = $(LDFLAGS) -dll SOLIBS = diff --git a/win32/win32.c b/win32/win32.c index ead75f37df..3bd857253a 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -29,6 +29,9 @@ #include <share.h> #include <shlobj.h> #include <mbstring.h> +#if _MSC_VER >= 1400 +#include <crtdbg.h> +#endif #ifdef __MINGW32__ #include <mswsock.h> #endif @@ -439,10 +442,29 @@ init_func(void) static void init_stdhandle(void); #if _MSC_VER >= 1400 -static void invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file, unsigned int line, uintptr_t dummy) +static void +invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file, unsigned int line, uintptr_t dummy) { // nothing to do } + +int ruby_w32_rtc_error; + +static int __cdecl +rtc_error_handler(int e, const char *src, int line, const char *exe, const char *fmt, ...) +{ + va_list ap; + VALUE str; + + if (!ruby_w32_rtc_error) return 0; + str = rb_sprintf("%s:%d: ", src, line); + va_start(ap, fmt); + rb_str_vcatf(str, fmt, ap); + va_end(ap); + rb_str_cat(str, "\n", 1); + rb_write_error2(RSTRING_PTR(str), RSTRING_LEN(str)); + return 0; +} #endif static CRITICAL_SECTION select_mutex; @@ -496,7 +518,9 @@ rb_w32_sysinit(int *argc, char ***argv) #if _MSC_VER >= 1400 static void set_pioinfo_extra(void); + _CrtSetReportMode(_CRT_ASSERT, 0); _set_invalid_parameter_handler(invalid_parameter); + _RTC_SetErrorFunc(rtc_error_handler); set_pioinfo_extra(); #endif @@ -4873,5 +4897,3 @@ rb_w32_fsopen(const char *path, const char *mode, int shflags) return f; } #endif - -RUBY_EXTERN int __cdecl _CrtDbgReportW() {return 0;} |