8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 17:23:03 +01:00

Update allowed C++ version (#7654)

* Update allowed C++ version.

* Build examples using C++11.

* Remove pre-C++11 fallback in examples code - thanks to Alex.
This commit is contained in:
Adriano dos Santos Fernandes 2023-09-18 07:14:06 -03:00 committed by GitHub
parent a54a3079d9
commit 93acbd1aef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 19 additions and 24 deletions

View File

@ -1,11 +1,12 @@
# Modern C++ features # Modern C++ features
We define here as "modern C++" features the ones introduced since C++17. These features should be used in a "controlled" form in Firebird code, as not all compilers fully support them. It's allowed to use in Firebird internal code C++ features up to and including C++17.
Only ones mentioned in this document could be used, but as necessities appears, discussion should be started in the devel list or pull requests. Public files (as API headers) is limited to C++11.
Exceptions to these rules should be listed below and must be agreed by the team,
discussing in the devel list or by pull request.
## Allowed features ## Allowed features
### C++17 ### C++20
- [if with init-statement](https://en.cppreference.com/w/cpp/language/if)

View File

@ -1604,7 +1604,7 @@ ISomePlugin implementation</i></font></p>
<p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt"><i>private:</i></font></p> <p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt"><i>private:</i></font></p>
<p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt"><i>IPluginConfig* <p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt"><i>IPluginConfig*
config;</i></font></p> config;</i></font></p>
<p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt"><i>FbSampleAtomic <p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt"><i>std::atomic_int
refCounter;</i></font></p> refCounter;</i></font></p>
<p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt"><i>IReferenceCounted* <p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt"><i>IReferenceCounted*
owner;</i></font></p> owner;</i></font></p>

View File

@ -25,6 +25,7 @@
*/ */
#include "../interfaces/ifaceExamples.h" #include "../interfaces/ifaceExamples.h"
#include <atomic>
namespace namespace
{ {
@ -189,7 +190,7 @@ private:
IPluginConfig* config; IPluginConfig* config;
ISC_UCHAR key; ISC_UCHAR key;
FbSampleAtomic refCounter; std::atomic_int refCounter;
IReferenceCounted* owner; IReferenceCounted* owner;
IConfigEntry* getEntry(CheckStatusWrapper* status, const char* entryName); IConfigEntry* getEntry(CheckStatusWrapper* status, const char* entryName);

View File

@ -25,6 +25,7 @@
*/ */
#include "../interfaces/ifaceExamples.h" #include "../interfaces/ifaceExamples.h"
#include <atomic>
using namespace Firebird; using namespace Firebird;
@ -121,7 +122,7 @@ private:
char savedKeyName[32]; char savedKeyName[32];
ISC_UCHAR key; ISC_UCHAR key;
FbSampleAtomic refCounter; std::atomic_int refCounter;
IReferenceCounted* owner; IReferenceCounted* owner;
void noKeyError(CheckStatusWrapper* status); void noKeyError(CheckStatusWrapper* status);

View File

@ -61,7 +61,7 @@ KEYGEN_objects=$(INTERMED)/keygen.o
TCWRAP_objects=$(INTERMED)/TcWrapper.o TCWRAP_objects=$(INTERMED)/TcWrapper.o
KEY_AUTH_objects=$(INTERMED)/ExtAuth.o KEY_AUTH_objects=$(INTERMED)/ExtAuth.o
CXXFLAGS=-std=c++17 -pthread -I$(ROOT)/include -fPIC $(TOMCRYPT_COMPILE) CXXFLAGS=-std=c++11 -pthread -I$(ROOT)/include -fPIC $(TOMCRYPT_COMPILE)
LDFLAGS=-pthread -L$(LIB) -Wl,-rpath,'$$ORIGIN/../lib' $(TOMCRYPT_LINK) LDFLAGS=-pthread -L$(LIB) -Wl,-rpath,'$$ORIGIN/../lib' $(TOMCRYPT_LINK)
LINK_LIBS=-lfbclient -ltomcrypt -ltommath LINK_LIBS=-lfbclient -ltomcrypt -ltommath

View File

@ -31,6 +31,7 @@
*/ */
#include "ifaceExamples.h" #include "ifaceExamples.h"
#include <atomic>
static IMaster* master = fb_get_master_interface(); static IMaster* master = fb_get_master_interface();
@ -66,7 +67,7 @@ private:
} }
}; };
FbSampleAtomic referenceCounter; std::atomic_int referenceCounter;
// we are using only single field (varchar) in a sample, therefore no strong alignment requirements. // we are using only single field (varchar) in a sample, therefore no strong alignment requirements.
// In general message alignment is the maximum field alignment in that message. // In general message alignment is the maximum field alignment in that message.

View File

@ -26,6 +26,7 @@
*/ */
#include "ifaceExamples.h" #include "ifaceExamples.h"
#include <atomic>
#ifndef WIN32 #ifndef WIN32
#include <unistd.h> #include <unistd.h>
@ -115,7 +116,7 @@ namespace
status.dispose(); status.dispose();
} }
FbSampleAtomic refCounter; std::atomic_int refCounter;
IAttachment* attachment; IAttachment* attachment;
volatile int counter; volatile int counter;
ThrowStatusWrapper status; ThrowStatusWrapper status;

View File

@ -28,13 +28,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined(__cplusplus) && (__cplusplus >= 201103L)
#include <atomic>
typedef std::atomic_int FbSampleAtomic;
#else
typedef int FbSampleAtomic;
#endif
#include <firebird/Interface.h> #include <firebird/Interface.h>
using namespace Firebird; using namespace Firebird;

View File

@ -33,7 +33,7 @@ FBCLIENT = $(FIREBIRD)/lib/libfbclient.so
# General Compiler and linker Defines for Linux # General Compiler and linker Defines for Linux
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
CXX = c++ CXX = c++
CXXFLAGS= -c -Wall -g3 -std=c++17 -fno-rtti $(INCLUDE) CXXFLAGS= -c -Wall -g3 -std=c++11 -fno-rtti $(INCLUDE)
RM = rm -f RM = rm -f
# #

View File

@ -173,9 +173,6 @@ Program Description
12.batch_isc.cpp Working with batch interface from ISC API. 12.batch_isc.cpp Working with batch interface from ISC API.
FbSampleAtomic typedef required in many examples.
dbcrypt - a sample of XOR database encryption (do not use in production!!!) dbcrypt - a sample of XOR database encryption (do not use in production!!!)