Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -148,10 +148,13 @@ # define OF_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) #else # define OF_GCC_VERSION 0 #endif +#define OF_STRINGIFY(s) OF_STRINGIFY2(s) +#define OF_STRINGIFY2(s) #s + #ifndef __has_feature # define __has_feature(x) 0 #endif #ifndef __has_attribute @@ -356,14 +359,16 @@ #define OF_RETAIN_COUNT_MAX UINT_MAX #define OF_NOT_FOUND SIZE_MAX #ifdef OBJC_COMPILING_RUNTIME -# define OF_ENSURE(cond) \ - do { \ - if OF_UNLIKELY (!(cond)) \ - OBJC_ERROR("Failed to ensure condition:\n" #cond); \ +# define OF_ENSURE(cond) \ + do { \ + if OF_UNLIKELY (!(cond)) \ + objc_error("ObjFWRT @ " __FILE__ ":" \ + OF_STRINGIFY(__LINE__), \ + "Failed to ensure condition:\n" #cond); \ } while(0) #else # define OF_ENSURE(cond) \ do { \ if OF_UNLIKELY (!(cond)) { \ Index: src/runtime/misc.m ================================================================== --- src/runtime/misc.m +++ src/runtime/misc.m @@ -51,28 +51,23 @@ { enumerationMutationHandler = handler; } void -objc_error(const char *file, unsigned int line, const char *format, ...) +objc_error(const char *title, const char *format, ...) { #ifdef OF_AMIGAOS -# define BUF_LEN 256 - char title[BUF_LEN]; +# define BUF_LEN 512 char message[BUF_LEN]; int status; va_list args; struct Library *IntuitionBase; # ifdef OF_AMIGAOS4 struct IntuitionIFace *IIntuition; # endif struct EasyStruct easy; - status = snprintf(title, BUF_LEN, "ObjFWRT @ %s:%u", file, line); - if (status <= 0 || status >= BUF_LEN) - title[0] = '\0'; - va_start(args, format); status = vsnprintf(message, BUF_LEN, format, args); if (status <= 0 || status >= BUF_LEN) message[0] = '\0'; va_end(args); @@ -109,11 +104,11 @@ #else va_list args; va_start(args, format); - fprintf(stderr, "[ObjFWRT @ %s:%u] ", file, line); + fprintf(stderr, "[%s] ", title); vfprintf(stderr, format, args); fprintf(stderr, "\n"); fflush(stderr); va_end(args); Index: src/runtime/private.h ================================================================== --- src/runtime/private.h +++ src/runtime/private.h @@ -341,13 +341,15 @@ return dtable->buckets[i]->buckets[j]; #endif } -extern void OF_NO_RETURN_FUNC objc_error(const char *_Nonnull file, - unsigned int line, const char *_Nonnull format, ...); -#define OBJC_ERROR(...) objc_error(__FILE__, __LINE__, __VA_ARGS__) +extern void OF_NO_RETURN_FUNC objc_error(const char *_Nonnull title, + const char *_Nonnull format, ...); +#define OBJC_ERROR(...) \ + objc_error("ObjFWRT @ " __FILE__ ":" OF_STRINGIFY(__LINE__), \ + __VA_ARGS__) #if defined(OF_ELF) # if defined(OF_X86_64) || defined(OF_X86) || defined(OF_POWERPC) || \ defined(OF_ARM64) || defined(OF_ARM) || \ defined(OF_MIPS64_N64) || defined(OF_MIPS) || \