Move the rest of macros from qglobal to QtPreprocessorSupport

We had only three macros left in QtGlobal:
* QT_STRINGIFY
* Q_UNUSED()
* Q_UNIMPLEMENTED()

There is no obvious existing header for them, so a new header is
created.
As a drive-by: add documentation for QT_STRINGIFY.

Task-number: QTBUG-106154
Task-number: QTBUG-99313
Change-Id: I2d051dd3e69f13602893a0f0d6968419479b6c23
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Ivan Solovev 2022-09-30 13:45:17 +02:00
parent dff985140a
commit e54ff7754d
5 changed files with 48 additions and 26 deletions

View File

@ -81,6 +81,7 @@ qt_internal_add_module(Core
global/qtconfigmacros.h
global/qtdeprecationmarkers.h
global/qtenvironmentvariables.cpp global/qtenvironmentvariables.h
global/qtpreprocessorsupport.h
global/qtrace_p.h
global/qtresource.h
global/qttranslation.h

View File

@ -227,16 +227,6 @@ void qAbort()
// localtime() -- but not localtime_r(), which we use when threaded
// strftime() -- not used (except in tests)
/*!
\macro Q_UNUSED(name)
\relates <QtGlobal>
Indicates to the compiler that the parameter with the specified
\a name is not used in the body of a function. This can be used to
suppress compiler warnings while allowing functions to be defined
with meaningful parameter names in their signatures.
*/
struct QInternal_CallBackTable
{
QList<QList<qInternalCallback>> callbacks;

View File

@ -25,10 +25,7 @@
#include <QtCore/qtconfigmacros.h>
#include <QtCore/qtcoreexports.h>
/* These two macros makes it possible to turn the builtin line expander into a
* string literal. */
#define QT_STRINGIFY2(x) #x
#define QT_STRINGIFY(x) QT_STRINGIFY2(x)
#include <QtCore/qtpreprocessorsupport.h>
inline void qt_noop(void) {}
@ -40,22 +37,10 @@ inline void qt_noop(void) {}
#include <QtCore/qtypes.h>
#include <QtCore/qtclasshelpermacros.h>
/*
Avoid "unused parameter" warnings
*/
#define Q_UNUSED(x) (void)x;
#ifndef __ASSEMBLER__
QT_BEGIN_NAMESPACE
#if defined(__cplusplus)
#if !defined(Q_UNIMPLEMENTED)
# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
#endif
QT_END_NAMESPACE
// We need to keep QTypeInfo, QSysInfo, QFlags, qDebug & family in qglobal.h for compatibility with Qt 4.
// Be careful when changing the order of these files.
#include <QtCore/qtypeinfo.h>

View File

@ -0,0 +1,26 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTPREPROCESSORSUPPORT_H
#define QTPREPROCESSORSUPPORT_H
#if 0
#pragma qt_class(QtPreprocessorSupport)
#pragma qt_sync_stop_processing
#endif
/* These two macros makes it possible to turn the builtin line expander into a
* string literal. */
#define QT_STRINGIFY2(x) #x
#define QT_STRINGIFY(x) QT_STRINGIFY2(x)
/*
Avoid "unused parameter" warnings
*/
#define Q_UNUSED(x) (void)x;
#if !defined(Q_UNIMPLEMENTED)
# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
#endif
#endif // QTPREPROCESSORSUPPORT_H

View File

@ -0,0 +1,20 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\macro Q_UNUSED(name)
\relates <QtPreprocessorSupport>
Indicates to the compiler that the parameter with the specified
\a name is not used in the body of a function. This can be used to
suppress compiler warnings while allowing functions to be defined
with meaningful parameter names in their signatures.
*/
/*!
\macro QT_STRINGIFY(arg)
\relates <QtPreprocessorSupport>
The macro can be used to turn the builtin line expander \a arg into a string
literal.
*/