2022-06-09 16:24:43 +00:00
|
|
|
// Copyright (C) 2022 The Qt Company Ltd.
|
2022-05-10 10:06:48 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
2021-06-22 15:37:55 +00:00
|
|
|
|
2022-10-05 12:39:41 +00:00
|
|
|
#include <QtCore/qglobal.h>
|
|
|
|
|
2021-07-30 15:51:07 +00:00
|
|
|
#ifndef @header_base_name_upper@_H
|
|
|
|
#define @header_base_name_upper@_H
|
2021-06-22 15:37:55 +00:00
|
|
|
|
|
|
|
#if defined(QT_SHARED) || !defined(QT_STATIC)
|
|
|
|
# if defined(QT_BUILD_@module_define_infix@_LIB)
|
|
|
|
# define Q_@module_define_infix@_EXPORT Q_DECL_EXPORT
|
|
|
|
# else
|
|
|
|
# define Q_@module_define_infix@_EXPORT Q_DECL_IMPORT
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# define Q_@module_define_infix@_EXPORT
|
|
|
|
#endif
|
|
|
|
|
2022-12-15 16:45:56 +00:00
|
|
|
#if !defined(QT_BUILD_@module_define_infix@_LIB) && !defined(QT_STATIC)
|
Long live QT_INLINE_SINCE!
We have now had several requests for inlining previously-exported
member functions, but no standard mechanism to effect it.
As QT_REMOVED_SINCE has shown, there is great value in having such a
standard mechanism, so here is one.
With this change, to inline a previously exported (member) function,
simply
- mark the declaration with QT_<MODULE>_INLINE_SINCE
- move the definition into the header file (outside the class),
- wrap it in QT_<MODULE>_INLINE_IMPL_SINCE
- #include the header into the module's removed_api.cpp
Just including the header into removed_api.cpp is enough, so you may
want to add a comment:
#include "header.h" // uses QT_<MODULE>_INLINE_SINCE
The effect is as follows:
- A TU in a _different_ library will see an inline declaration,
followed by the definition, and so it will see a normal inline
function.
- A TU in the same library will, however, see a non-inline
declaration, to avoid the ODR violation that at least GCC/ld are
able to detect.
- When QT_<MODULE>_BUILD_REMOVED_API is in effect, the TU will also
see the definition, which is the same setup as before the change,
except in a different TU, and therefore export the member.
- When, OTOH, QT_<MODULE>_BUILD_REMOVED_API is _not_ in effect, the
TU will see no declaration, assuming (correctly), that the
definition will be supplied by a different TU.
This is, of course, an ODR violation, but not worse than what we do
elsewhere, as the definitions differ only between library and user.
The function is inline only for the users of the library, not the
library itself, which will still see the function as non-inline. If
inlining is critical within the library, too, the existing function
should call a new inline function, and calls in the same library should
be changed to call the new inline function instead.
Use the new mechanism to inline the QLocale ctor we intended to inline
for 6.3, but couldn't, because we hadn't found the magic incantation,
yet. Thiago found it a few weeks later, and this is what this patch is
based on.
Fixes: QTBUG-100452
Pick-to: 6.4
Change-Id: Ia0030cddc64b6b92edfed860170d5204aa74b953
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-31 10:27:49 +00:00
|
|
|
/* outside library → inline decl + defi */
|
2022-12-15 16:45:56 +00:00
|
|
|
/* static builds treat everything as part of the library, so they never inline */
|
Long live QT_INLINE_SINCE!
We have now had several requests for inlining previously-exported
member functions, but no standard mechanism to effect it.
As QT_REMOVED_SINCE has shown, there is great value in having such a
standard mechanism, so here is one.
With this change, to inline a previously exported (member) function,
simply
- mark the declaration with QT_<MODULE>_INLINE_SINCE
- move the definition into the header file (outside the class),
- wrap it in QT_<MODULE>_INLINE_IMPL_SINCE
- #include the header into the module's removed_api.cpp
Just including the header into removed_api.cpp is enough, so you may
want to add a comment:
#include "header.h" // uses QT_<MODULE>_INLINE_SINCE
The effect is as follows:
- A TU in a _different_ library will see an inline declaration,
followed by the definition, and so it will see a normal inline
function.
- A TU in the same library will, however, see a non-inline
declaration, to avoid the ODR violation that at least GCC/ld are
able to detect.
- When QT_<MODULE>_BUILD_REMOVED_API is in effect, the TU will also
see the definition, which is the same setup as before the change,
except in a different TU, and therefore export the member.
- When, OTOH, QT_<MODULE>_BUILD_REMOVED_API is _not_ in effect, the
TU will see no declaration, assuming (correctly), that the
definition will be supplied by a different TU.
This is, of course, an ODR violation, but not worse than what we do
elsewhere, as the definitions differ only between library and user.
The function is inline only for the users of the library, not the
library itself, which will still see the function as non-inline. If
inlining is critical within the library, too, the existing function
should call a new inline function, and calls in the same library should
be changed to call the new inline function instead.
Use the new mechanism to inline the QLocale ctor we intended to inline
for 6.3, but couldn't, because we hadn't found the magic incantation,
yet. Thiago found it a few weeks later, and this is what this patch is
based on.
Fixes: QTBUG-100452
Pick-to: 6.4
Change-Id: Ia0030cddc64b6b92edfed860170d5204aa74b953
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-31 10:27:49 +00:00
|
|
|
# define QT_@module_define_infix@_INLINE_SINCE(major, minor) inline
|
|
|
|
# define QT_@module_define_infix@_INLINE_IMPL_SINCE(major, minor) 1
|
|
|
|
#elif defined(QT_@module_define_infix@_BUILD_REMOVED_API)
|
2022-07-19 13:07:06 +00:00
|
|
|
/* inside library, inside removed_api.cpp:
|
|
|
|
* keep deprecated API → non-inline decl;
|
|
|
|
* remove deprecated API → inline decl;
|
|
|
|
* definition is always available */
|
|
|
|
# define QT_@module_define_infix@_INLINE_SINCE(major, minor) \
|
|
|
|
QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */)
|
Long live QT_INLINE_SINCE!
We have now had several requests for inlining previously-exported
member functions, but no standard mechanism to effect it.
As QT_REMOVED_SINCE has shown, there is great value in having such a
standard mechanism, so here is one.
With this change, to inline a previously exported (member) function,
simply
- mark the declaration with QT_<MODULE>_INLINE_SINCE
- move the definition into the header file (outside the class),
- wrap it in QT_<MODULE>_INLINE_IMPL_SINCE
- #include the header into the module's removed_api.cpp
Just including the header into removed_api.cpp is enough, so you may
want to add a comment:
#include "header.h" // uses QT_<MODULE>_INLINE_SINCE
The effect is as follows:
- A TU in a _different_ library will see an inline declaration,
followed by the definition, and so it will see a normal inline
function.
- A TU in the same library will, however, see a non-inline
declaration, to avoid the ODR violation that at least GCC/ld are
able to detect.
- When QT_<MODULE>_BUILD_REMOVED_API is in effect, the TU will also
see the definition, which is the same setup as before the change,
except in a different TU, and therefore export the member.
- When, OTOH, QT_<MODULE>_BUILD_REMOVED_API is _not_ in effect, the
TU will see no declaration, assuming (correctly), that the
definition will be supplied by a different TU.
This is, of course, an ODR violation, but not worse than what we do
elsewhere, as the definitions differ only between library and user.
The function is inline only for the users of the library, not the
library itself, which will still see the function as non-inline. If
inlining is critical within the library, too, the existing function
should call a new inline function, and calls in the same library should
be changed to call the new inline function instead.
Use the new mechanism to inline the QLocale ctor we intended to inline
for 6.3, but couldn't, because we hadn't found the magic incantation,
yet. Thiago found it a few weeks later, and this is what this patch is
based on.
Fixes: QTBUG-100452
Pick-to: 6.4
Change-Id: Ia0030cddc64b6b92edfed860170d5204aa74b953
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-31 10:27:49 +00:00
|
|
|
# define QT_@module_define_infix@_INLINE_IMPL_SINCE(major, minor) 1
|
|
|
|
#else
|
2022-07-19 13:07:06 +00:00
|
|
|
/* inside library, outside removed_api.cpp:
|
|
|
|
* keep deprecated API → non-inline decl, no defi;
|
|
|
|
* remove deprecated API → inline decl, defi */
|
|
|
|
# define QT_@module_define_infix@_INLINE_SINCE(major, minor) \
|
|
|
|
QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */)
|
|
|
|
# define QT_@module_define_infix@_INLINE_IMPL_SINCE(major, minor) \
|
|
|
|
QT_IF_DEPRECATED_SINCE(major, minor, 1, 0)
|
Long live QT_INLINE_SINCE!
We have now had several requests for inlining previously-exported
member functions, but no standard mechanism to effect it.
As QT_REMOVED_SINCE has shown, there is great value in having such a
standard mechanism, so here is one.
With this change, to inline a previously exported (member) function,
simply
- mark the declaration with QT_<MODULE>_INLINE_SINCE
- move the definition into the header file (outside the class),
- wrap it in QT_<MODULE>_INLINE_IMPL_SINCE
- #include the header into the module's removed_api.cpp
Just including the header into removed_api.cpp is enough, so you may
want to add a comment:
#include "header.h" // uses QT_<MODULE>_INLINE_SINCE
The effect is as follows:
- A TU in a _different_ library will see an inline declaration,
followed by the definition, and so it will see a normal inline
function.
- A TU in the same library will, however, see a non-inline
declaration, to avoid the ODR violation that at least GCC/ld are
able to detect.
- When QT_<MODULE>_BUILD_REMOVED_API is in effect, the TU will also
see the definition, which is the same setup as before the change,
except in a different TU, and therefore export the member.
- When, OTOH, QT_<MODULE>_BUILD_REMOVED_API is _not_ in effect, the
TU will see no declaration, assuming (correctly), that the
definition will be supplied by a different TU.
This is, of course, an ODR violation, but not worse than what we do
elsewhere, as the definitions differ only between library and user.
The function is inline only for the users of the library, not the
library itself, which will still see the function as non-inline. If
inlining is critical within the library, too, the existing function
should call a new inline function, and calls in the same library should
be changed to call the new inline function instead.
Use the new mechanism to inline the QLocale ctor we intended to inline
for 6.3, but couldn't, because we hadn't found the magic incantation,
yet. Thiago found it a few weeks later, and this is what this patch is
based on.
Fixes: QTBUG-100452
Pick-to: 6.4
Change-Id: Ia0030cddc64b6b92edfed860170d5204aa74b953
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-31 10:27:49 +00:00
|
|
|
#endif
|
|
|
|
|
2022-01-31 10:10:26 +00:00
|
|
|
#ifdef QT_@module_define_infix@_BUILD_REMOVED_API
|
2022-06-09 16:24:43 +00:00
|
|
|
# define QT_@module_define_infix@_REMOVED_SINCE(major, minor) QT_DEPRECATED_SINCE(major, minor)
|
2022-01-31 10:10:26 +00:00
|
|
|
#else
|
2022-06-09 16:24:43 +00:00
|
|
|
# define QT_@module_define_infix@_REMOVED_SINCE(major, minor) 0
|
2022-01-31 10:10:26 +00:00
|
|
|
#endif
|
|
|
|
|
2021-07-30 15:51:07 +00:00
|
|
|
#endif // @header_base_name_upper@_H
|