1
0
mirror of https://github.com/eclipse/paho.mqtt.cpp.git synced 2025-05-09 03:11:23 +08:00

#442 g++ complains with multiple definition of static constexpr for mixed C++11/17 builds

This commit is contained in:
fpagliughi 2023-11-11 09:47:44 -05:00
parent f90f3069f1
commit ab98b289b6
8 changed files with 23 additions and 31 deletions

View File

@ -25,9 +25,7 @@ namespace mqtt {
const std::chrono::seconds client::DFLT_TIMEOUT = std::chrono::seconds(30);
#if __cplusplus < 201703L
constexpr int client::DFLT_QOS;
#endif
const int client::DFLT_QOS = 1;
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,7 +1,7 @@
// message.cpp
/*******************************************************************************
* Copyright (c) 2013-2020 Frank Pagliughi <fpagliughi@mindspring.com>
* Copyright (c) 2013-2023 Frank Pagliughi <fpagliughi@mindspring.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -25,10 +25,8 @@ namespace mqtt {
/////////////////////////////////////////////////////////////////////////////
#if __cplusplus < 201703L
constexpr int message::DFLT_QOS;
constexpr bool message::DFLT_RETAINED;
#endif
const int message::DFLT_QOS = 0;
const bool message::DFLT_RETAINED = false;
const MQTTAsync_message message::DFLT_C_STRUCT = MQTTAsync_message_initializer;

View File

@ -6,7 +6,7 @@
/////////////////////////////////////////////////////////////////////////////
/*******************************************************************************
* Copyright (c) 2013-2020 Frank Pagliughi <fpagliughi@mindspring.com>
* Copyright (c) 2013-2023 Frank Pagliughi <fpagliughi@mindspring.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -40,7 +40,7 @@ class client : private callback
/** An arbitrary, but relatively long timeout */
static const std::chrono::seconds DFLT_TIMEOUT;
/** The default quality of service */
static constexpr int DFLT_QOS = 1;
static const int DFLT_QOS; // =1;
/** The actual client */
async_client cli_;

View File

@ -6,7 +6,7 @@
/////////////////////////////////////////////////////////////////////////////
/*******************************************************************************
* Copyright (c) 2013-2020 Frank Pagliughi <fpagliughi@mindspring.com>
* Copyright (c) 2013-2023 Frank Pagliughi <fpagliughi@mindspring.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -55,9 +55,9 @@ class message
{
public:
/** The default QoS for a message */
static constexpr int DFLT_QOS = 0;
static const int DFLT_QOS; // =0
/** The default retained flag */
static constexpr bool DFLT_RETAINED = false;
static const bool DFLT_RETAINED; // =false
private:
/** Initializer for the C struct (from the C library) */

View File

@ -53,17 +53,17 @@ public:
using const_ptr_t = std::shared_ptr<const subscribe_options>;
/** Don't receive our own publications */
static constexpr bool SUBSCRIBE_NO_LOCAL = true;
static const bool SUBSCRIBE_NO_LOCAL; // =true;
/** Receive our own publications */
static constexpr bool SUBSCRIBE_LOCAL = false;
static const bool SUBSCRIBE_LOCAL; // =false;
/**
* Retain flag is only set on publications sent by a broker if in
* response to a subscribe request
*/
static constexpr bool NO_RETAIN_AS_PUBLISHED = false;
static const bool NO_RETAIN_AS_PUBLISHED; // =false;
/** Keep the retain flag as on the original publish message */
static constexpr bool RETAIN_AS_PUBLISHED = true;
static const bool RETAIN_AS_PUBLISHED; // =true;
/** The options for subscription retain handling */
enum RetainHandling {

View File

@ -7,7 +7,7 @@
/*******************************************************************************
* Copyright (c) 2016 Guilherme M. Ferreira <guilherme.maciel.ferreira@gmail.com>
* Copyright (c) 2016-2019 Frank Pagliughi <fpagliughi@mindspring.com>
* Copyright (c) 2016-2023 Frank Pagliughi <fpagliughi@mindspring.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -49,9 +49,9 @@ class will_options
{
public:
/** The default QoS for the LWT, if unspecified */
static constexpr int DFLT_QOS = 0;
static const int DFLT_QOS; // =0;
/** The defalut retained flag for LWT, if unspecified */
static constexpr bool DFLT_RETAINED = false;
static const bool DFLT_RETAINED; // =false;
private:
/** A default C struct to support re-initializing variables */

View File

@ -22,13 +22,11 @@ namespace mqtt {
/////////////////////////////////////////////////////////////////////////////
#if __cplusplus < 201703L
constexpr bool subscribe_options::SUBSCRIBE_NO_LOCAL;
constexpr bool subscribe_options::SUBSCRIBE_LOCAL;
const bool subscribe_options::SUBSCRIBE_NO_LOCAL = true;
const bool subscribe_options::SUBSCRIBE_LOCAL = false;
constexpr bool subscribe_options::NO_RETAIN_AS_PUBLISHED;
constexpr bool subscribe_options::RETAIN_AS_PUBLISHED;
#endif
const bool subscribe_options::NO_RETAIN_AS_PUBLISHED = false;
const bool subscribe_options::RETAIN_AS_PUBLISHED = true;
/////////////////////////////////////////////////////////////////////////////
// end namespace 'mqtt'

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017-2020 Frank Pagliughi <fpagliughi@mindspring.com>
* Copyright (c) 2017-2023 Frank Pagliughi <fpagliughi@mindspring.com>
* Copyright (c) 2016 Guilherme M. Ferreira <guilherme.maciel.ferreira@gmail.com>
*
* All rights reserved. This program and the accompanying materials
@ -22,10 +22,8 @@
namespace mqtt {
#if __cplusplus < 201703L
constexpr int will_options::DFLT_QOS;
constexpr bool will_options::DFLT_RETAINED;
#endif
const int will_options::DFLT_QOS = 0;
const bool will_options::DFLT_RETAINED = false;
const MQTTAsync_willOptions will_options::DFLT_C_STRUCT = MQTTAsync_willOptions_initializer;