Add macros to warn once ... eg for deprecated methods/functions.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19395 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2004-05-24 16:08:03 +00:00
parent 110a61f7d9
commit d5ca12b42a
2 changed files with 36 additions and 0 deletions

View file

@ -341,6 +341,39 @@ GS_EXPORT BOOL NSDeallocateZombies;
#define NSDebugMRLog(object, msg)
#endif
/**
* Macro to log a message only the first time it is encountered.<br />
* Not entirely thread safe ... but that's not really important,
* it just means that it's possible for the message to be logged
* more than once if two threads call it simultaneously when it
* has not already been called.<br />
* Use this from inside a function. Pass an NSString as a format,
* followed by zero or more arguments for the format string.
* Example: GSOnceMLog(@"This function is deprecated, use another");
*/
#define GSOnceFLog(format, args...) \
do { static BOOL beenHere = NO; if (beenHere == NO) {\
NSString *fmt = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, format); \
beenHere = YES; \
NSLog(fmt , ## args); }} while (0)
/**
* Macro to log a message only the first time it is encountered.<br />
* Not entirely thread safe ... but that's not really important,
* it just means that it's possible for the message to be logged
* more than once if two threads call it simultaneously when it
* has not already been called.<br />
* Use this from inside a method. Pass an NSString as a format
* followed by zero or more arguments for the format string.<br />
* Example: GSOnceMLog(@"This method is deprecated, use another");
*/
#define GSOnceMLog(format, args...) \
do { static BOOL beenHere = NO; if (beenHere == NO) {\
NSString *fmt = GSDebugMethodMsg( \
self, _cmd, __FILE__, __LINE__, format); \
beenHere = YES; \
NSLog(fmt , ## args); }} while (0)
#ifdef GSWARN