diff --git a/doc/README.modern_cpp.md b/doc/README.modern_cpp.md index 0d367aa2d4..936cc611a3 100644 --- a/doc/README.modern_cpp.md +++ b/doc/README.modern_cpp.md @@ -1,11 +1,12 @@ # 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 -### C++17 - -- [if with init-statement](https://en.cppreference.com/w/cpp/language/if) +### C++20 diff --git a/doc/Using_OO_API.html b/doc/Using_OO_API.html index 6cd1eca49a..a59b05ef5f 100644 --- a/doc/Using_OO_API.html +++ b/doc/Using_OO_API.html @@ -1604,7 +1604,7 @@ ISomePlugin implementation

private:

IPluginConfig* config;

-

FbSampleAtomic +

std::atomic_int refCounter;

IReferenceCounted* owner;

@@ -2777,7 +2777,7 @@ interface – replaces (partially) isc_stmt_handle.

behavior.

  • void setCursorName(StatusType* status, const char* name) – replaces - isc_dsql_set_cursor_name(). + isc_dsql_set_cursor_name().

  • void free(StatusType* status) – free statement, releases interface on @@ -3817,4 +3817,4 @@ release of it.

    - \ No newline at end of file + diff --git a/examples/dbcrypt/CryptKeyHolder.cpp b/examples/dbcrypt/CryptKeyHolder.cpp index efa57df60f..3177ee5c71 100644 --- a/examples/dbcrypt/CryptKeyHolder.cpp +++ b/examples/dbcrypt/CryptKeyHolder.cpp @@ -25,6 +25,7 @@ */ #include "../interfaces/ifaceExamples.h" +#include namespace { @@ -189,7 +190,7 @@ private: IPluginConfig* config; ISC_UCHAR key; - FbSampleAtomic refCounter; + std::atomic_int refCounter; IReferenceCounted* owner; IConfigEntry* getEntry(CheckStatusWrapper* status, const char* entryName); diff --git a/examples/dbcrypt/DbCrypt.cpp b/examples/dbcrypt/DbCrypt.cpp index 6b0260eb27..643bfd9fab 100644 --- a/examples/dbcrypt/DbCrypt.cpp +++ b/examples/dbcrypt/DbCrypt.cpp @@ -25,6 +25,7 @@ */ #include "../interfaces/ifaceExamples.h" +#include using namespace Firebird; @@ -121,7 +122,7 @@ private: char savedKeyName[32]; ISC_UCHAR key; - FbSampleAtomic refCounter; + std::atomic_int refCounter; IReferenceCounted* owner; void noKeyError(CheckStatusWrapper* status); diff --git a/examples/extauth/Makefile b/examples/extauth/Makefile index 3c8b878d22..9da7bbd357 100644 --- a/examples/extauth/Makefile +++ b/examples/extauth/Makefile @@ -61,7 +61,7 @@ KEYGEN_objects=$(INTERMED)/keygen.o TCWRAP_objects=$(INTERMED)/TcWrapper.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) LINK_LIBS=-lfbclient -ltomcrypt -ltommath diff --git a/examples/interfaces/05.user_metadata.cpp b/examples/interfaces/05.user_metadata.cpp index 9d034598ec..e313499b8e 100644 --- a/examples/interfaces/05.user_metadata.cpp +++ b/examples/interfaces/05.user_metadata.cpp @@ -31,6 +31,7 @@ */ #include "ifaceExamples.h" +#include 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. // In general message alignment is the maximum field alignment in that message. diff --git a/examples/interfaces/08.events.cpp b/examples/interfaces/08.events.cpp index a0c51c301d..b122220657 100644 --- a/examples/interfaces/08.events.cpp +++ b/examples/interfaces/08.events.cpp @@ -26,6 +26,7 @@ */ #include "ifaceExamples.h" +#include #ifndef WIN32 #include @@ -115,7 +116,7 @@ namespace status.dispose(); } - FbSampleAtomic refCounter; + std::atomic_int refCounter; IAttachment* attachment; volatile int counter; ThrowStatusWrapper status; diff --git a/examples/interfaces/ifaceExamples.h b/examples/interfaces/ifaceExamples.h index cfcb1f9dca..f38fe74cdd 100644 --- a/examples/interfaces/ifaceExamples.h +++ b/examples/interfaces/ifaceExamples.h @@ -28,13 +28,6 @@ #include #include -#if defined(__cplusplus) && (__cplusplus >= 201103L) -#include -typedef std::atomic_int FbSampleAtomic; -#else -typedef int FbSampleAtomic; -#endif - #include using namespace Firebird; diff --git a/examples/interfaces/makefile b/examples/interfaces/makefile index b65dba90a7..bca55ff336 100644 --- a/examples/interfaces/makefile +++ b/examples/interfaces/makefile @@ -33,7 +33,7 @@ FBCLIENT = $(FIREBIRD)/lib/libfbclient.so # General Compiler and linker Defines for Linux # --------------------------------------------------------------------- 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 # diff --git a/examples/readme b/examples/readme index c0b19612f8..9362668bf7 100644 --- a/examples/readme +++ b/examples/readme @@ -173,9 +173,6 @@ Program Description 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!!!)