Travis Vitek wrote: > > >> Martin Sebor wrote: >> >> Eric Lemings wrote: >>> >>> Is there an macro function (or similar macro function) that calls the >>> rw_assert() function automatically passing it the __FILE__ >>> and __LINE__ arguments? >> Unfortunately, there isn't. No. rw_assert() is a variable >> argument function and since C99 varargs macros haven't been >> introduced into C++ yet not all compilers support them. >> > > Unless I'm misunderstanding what we are talking about, it seems that we > can get around that pretty easily.. But that's C++! ;-) No, seriously, I like it. IMO, the biggest problem with the printf-like interface is that it's error-prone. It would be nice to be able to just pass in the arguments w/o having to worry about getting the directives right, but that would require quite a bit of code in the rwtest headers and wouldn't be namespace clean. Martin > > // in driver.h > struct rw_diag_obj > { > rw_diag_obj (diag_t diag, const char* file, int line) > : diag_(diag), file_(file), line_(line) { } > > // implemented in driver.cpp > bool operator()(int success, const char* fmt, ...); > > const diag_t diag_; > const char const* file_; > const int line_; > }; > > // someone will probably want to select better names > #define rw_fatal_x rw_diag_obj(diag_fatal , __FILE__, __LINE__) > #define rw_error_x rw_diag_obj(diag_error , __FILE__, __LINE__) > #define rw_assert_x rw_diag_obj(diag_assert, __FILE__, __LINE__) > #define rw_warn_x rw_diag_obj(diag_warn , __FILE__, __LINE__) > #define rw_note_x rw_diag_obj(diag_note , __FILE__, __LINE__) > > // in driver.cpp > bool rw_diag_obj::operator()(int success, const char* fmt, ...) > { > va_list va; > va_start (va, fmt); > > _rw_vdiag (diag_, 0 == success, file_, line_, fmt, va); > > va_end (va); > > return success; > } > > There might be a small amount of overhead to do this, but it should be > optimized in most cases. > > Travis > >> Martin >>