Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at


« XPCOM API Reference


Inherit from this C++ class to add canonical support for nsISupportsWeakReference.

See Weak reference for detailed description of weak references.

#include "nsWeakReference.h"

class nsSupportsWeakReference { ... };


In addition to inheriting from this class, you will need to ensure that your nsISupports::QueryInterface implementation exposes nsISupportsWeakReference as a supported interface.

To use this class, you must link your component or application against the XPCOM Glue library.

Example code

 // Supporting weak references to a hypothetical implementation
 // of the nsIFoo interface...

 #include "nsWeakReference.h"
 #include "nsIFoo.h"

 class MyFoo : public nsIFoo, public nsSupportsWeakReference


 NS_IMPL_ISUPPORTS2(MyFoo, nsIFoo, nsISupportsWeakReference)


See also

nsISupports::QueryInterface , nsISupportsWeakReference

Document Tags and Contributors

 Contributors to this page: Sheppy, gsvelto, Nickolay, Pmash
 Last updated by: Sheppy,