usage of KDE_DEPRECATED

Luciano Montanaro mikelima at cirulla.net
Wed Mar 1 09:44:41 GMT 2006


On Wednesday 01 March 2006 07:46, Christian Ehrlicher wrote:
> Hi,
>
> Can someone tell me why I need to place KDE_DEPRECATED behind the
> deprecated function and why it won't work when it's written before? Qt's
> deprecated-macro is placed before the function and works fine. The
> problem is that msvc only allows it in front of the function and
> therefore we can't use KDE_DEPRECATED for msvc...

KDE_DEPRECATED expands to __attribute__((deprecated)) with gcc, which should 
be put after the function declaration to work. I think this limitation has 
been lifted for newer gcc versions, so maybe it can be put before the 
function declaration as for the inline function.

Here is the relevant comment from kdemacros.h:

 *
 * The KDE_DEPRECATED macro can be used to trigger compile-time warnings
 * with newer compilers when deprecated functions are used.
 *
 * For non-inline functions, the macro gets inserted at the very end of the
 * function declaration, right before the semicolon:
 *
 * \code
 * DeprecatedConstructor() KDE_DEPRECATED;
 * void deprecatedFunctionA() KDE_DEPRECATED;
 * int deprecatedFunctionB() const KDE_DEPRECATED;
 * \endcode
 *
 * Functions which are implemented inline are handled differently: for them,
 * the KDE_DEPRECATED macro is inserted at the front, right before the 
return
 * type, but after "static" or "virtual":
 *
 * \code
 * KDE_DEPRECATED void deprecatedInlineFunctionA() { .. }
 * virtual KDE_DEPRECATED int deprecatedInlineFunctionB() { .. }
 * static KDE_DEPRECATED bool deprecatedInlineFunctionC() { .. }
 * \endcode
 *
 * You can also mark whole structs or classes as deprecated, by inserting 
the
 * KDE_DEPRECATED macro after the struct/class keyword, but before the
 * name of the struct/class:
 *
 * \code
 * class KDE_DEPRECATED DeprecatedClass { };
 * struct KDE_DEPRECATED DeprecatedStruct { };
 * \endcode
 *
 * \note

>
> Christian

-- 
Luciano Montanaro //
              \\ //
               \x/ www.cirulla.net




More information about the kde-core-devel mailing list