Closed Bug 263585 Opened 20 years ago Closed 17 years ago

Adding NS_DEPRECATED macro to nscore.h

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: zack, Unassigned)

References

Details

Attachments

(1 file)

Are there any objection for adding NS_DEPRECATED macro? The macro placed as 
specified in the documentation (attached patch) makes the compiler emit 
warning whenever a method/class marked as NS_DEPRECATED is used. 
Works correctly with GCC (>=3.2) and MSVC (>=7).
Severity: normal → enhancement
OS: Linux → All
Hardware: Other → All
Comment on attachment 161551 [details] [diff] [review]
NS_DEPRECATED patch

>+ * Functions which are implemented inline are handled differently: for them,
>+ * the NS_DEPRECATED macro is inserted at the front, right before the return
>+ * type, but after "static" or "virtual":
>+ *
>+ * \code
>+ * NS_DEPRECATED void DeprecatedInlineFunctionA() { .. }
>+ * virtual NS_DEPRECATED int DeprecatedInlineFunctionB() { .. }
>+ * static NS_DEPRECATED bool DeprecatedInlineFunctionC() { .. }
>+ * \end

Does the other way work for inline functions?  This way isn't documented in the
gcc info page.

>+ * You can also mark whole structs or classes as deprecated, by inserting the
>+ * NS_DEPRECATED macro after the struct/class keyword, but before the
>+ * name of the struct/class:
>+ *
>+ * \code
>+ * class NS_DEPRECATED DeprecatedClass { };
>+ * struct NS_DEPRECATED DeprecatedStruct { };
>+ * \endcode
>+ */
>+#ifndef NS_DEPRECATED
>+#if __GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)
>+  /* gcc >= 3.2 */
>+# define NS_DEPRECATED __attribute__ ((deprecated))
>+#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
>+  /* msvc >= 7 */
>+# define NS_DEPRECATED __declspec(deprecated)
>+#else
>+# define NS_DEPRECATED
>+#endif

Does MSVC allow this in typedefs and variables as well?
(In reply to comment #2) 
> Does the other way work for inline functions?  This way isn't documented in 
the 
> gcc info page. 
 
No, it doesn't. I have to admit it's a little confusing and was also the 
reason for the rather extensive documentation for it. I never had enough time 
to create a GCC docs patch though. 
   
> Does MSVC allow this in typedefs and variables as well? 
 
Good question and to be honest I'm not sure. I don't have a MSVC >=7 box here 
at the moment to test it. 
Assignee: dougt → nobody
QA Contact: xpcom
Fixed by checking of bug 414063
Status: NEW → RESOLVED
Closed: 17 years ago
Depends on: 414063
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: