From aec952125146ef754b755f75bf9281d16e837155 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 18 Dec 2013 23:41:54 -0800 Subject: Visual Studio port. --- includes/Handle.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'includes/Handle.h') diff --git a/includes/Handle.h b/includes/Handle.h index 15415a6..941748e 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -30,6 +30,12 @@ class BaseEvent; }; +#ifdef _MSC_VER +#define WARN_UNUSED_RESULT +#else +#define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#endif + class Handle { public: virtual ~Handle() { AAssert(m_refCount == 0, "Do not use handles directly; warp them in IO<>"); } @@ -44,8 +50,8 @@ class Handle { virtual bool canSeek(); virtual bool canRead(); virtual bool canWrite(); - virtual ssize_t read(void * buf, size_t count) throw (GeneralException) __attribute__((warn_unused_result)); - virtual ssize_t write(const void * buf, size_t count) throw (GeneralException) __attribute__((warn_unused_result)); + virtual ssize_t read(void * buf, size_t count) throw (GeneralException) WARN_UNUSED_RESULT; + virtual ssize_t write(const void * buf, size_t count) throw (GeneralException) WARN_UNUSED_RESULT; virtual void rseek(off_t offset, int whence = SEEK_SET) throw (GeneralException); virtual void wseek(off_t offset, int whence = SEEK_SET) throw (GeneralException); virtual off_t rtell() throw (GeneralException); @@ -77,11 +83,11 @@ class Handle { // these need to be changed into Future<>s template - ssize_t writeString(const char (&str)[L]) __attribute__((warn_unused_result)); - ssize_t writeString(const String & str) __attribute__((warn_unused_result)) { return forceWrite(str.to_charp(), str.strlen()); } - ssize_t writeString(const char * str, ssize_t len) __attribute__((warn_unused_result)) { return forceWrite(str, len); } - ssize_t forceRead(void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException) __attribute__((warn_unused_result)); - ssize_t forceWrite(const void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException) __attribute__((warn_unused_result)); + ssize_t writeString(const char (&str)[L]) WARN_UNUSED_RESULT; + ssize_t writeString(const String & str) WARN_UNUSED_RESULT { return forceWrite(str.to_charp(), str.strlen()); } + ssize_t writeString(const char * str, ssize_t len) WARN_UNUSED_RESULT { return forceWrite(str, len); } + ssize_t forceRead(void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException) WARN_UNUSED_RESULT; + ssize_t forceWrite(const void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException) WARN_UNUSED_RESULT; protected: Handle() : m_refCount(0) { } -- cgit v1.2.3