Comments (3)
It seems challenging to simultaneously compile with no warnings both on C++11 platforms that deprecate auto_ptr, and C++03 platforms that don't have unique_ptr. Is there a way to disable the warning?
from cryptopp.
Cleared through a few different commits. Some are listed below.
The general strategy was to identify C++11, identify ancient C++11 standard libraries, and then swap-in unique_ptr
for auto_ptr
if available. The identification and swap-in occurred in smartptr.h
:
// Hack ahead. Apple's standard library does not have C++'s unique_ptr in C++11. We can't
// test for unique_ptr directly because some of the non-Apple Clangs on OS X fail the same
// way. However, modern standard libraries have <forward_list>, so we test for it instead.
// Thanks to Jonathan Wakely for devising the clever test for modern/ancient versions.
// Visual Studio did not add template aliases until VS 2015 (v19.00). Compile failed under
// Visual Studio 2010 (v16.00) and Visual Studio 2012 (v17.00).
#if (__cplusplus >= 201103L) || (_MSC_VER >= 1900)
# if defined(__clang__)
# if (__has_include(<forward_list>))
# define CRYPTOPP_HAVE_UNIQUE_PTR 1
# endif
# else
# define CRYPTOPP_HAVE_UNIQUE_PTR 1
# endif
#endif
// The result of below is a CryptoPP::auto_ptr in both cases
#ifdef CRYPTOPP_HAVE_UNIQUE_PTR
template<typename T>
using auto_ptr = std::unique_ptr<T>;
#else
using std::auto_ptr;
#endif
Then, in the source code:
PK_Verifier::VerifyMessage(const byte*, size_t, const byte*, size_t) const
{
using CryptoPP::auto_ptr;
auto_ptr<PK_MessageAccumulator> m(NewVerificationAccumulator());
...
}
For testing on BSDs, Linux, OS X and Unix, you would build in one of four configurations to ensure correctness:
# c++ -DNDEBUG -g2 -O3 ...
export CXXFLAGS=""
make
# c++ -std=c++11 -DNDEBUG -g2 -O3 ...
export CXXFLAGS="-std=c++11"
make
# c++ -stdlib=libc++ -DNDEBUG -g2 -O3 ...
export CXXFLAGS="-stdlib=libc++"
make
# c++ -std=c++11 -stdlib=libc++ -DNDEBUG -g2 -O3 ...
export CXXFLAGS="-std=c++11 -stdlib=libc++"
make
from cryptopp.
It seems challenging to simultaneously compile with no warnings both on C++11 platforms that deprecate
auto_ptr
, and C++03 platforms that don't haveunique_ptr
...
This observation was insightful. I found we were able to sidestep most of the warnings by switching to Crypto++'s member_ptr
. It provides the same basic functionality we needed, and it has both reset
and release
. It does not require the [sometimes] convoluted logic to determine when C++11 is really available, and does not require template declaration support.
We have one place we could not cleanly cut over, and that was in validat1.cpp
(around line 575). So warnings went from "a lot" to "just one".
from cryptopp.
Related Issues (20)
- ARIA/CTR mode self test failures HOT 2
- AES/CFB and AES/CTR modes self test failures on ARMv7 HOT 1
- SIMON128 Asan failures on POWER8 HOT 1
- Warning in validat2.cpp
- CRYPTOPP_VERSION has reached its limits HOT 3
- CRYPTOPP_DISABLE_ASM is broken in 8.9.0 for MSVC x64 builds HOT 20
- Unable to link using MSYS2 Clang64 toolchain HOT 8
- An invalid parameter was passed to a function that considers invalid parameters fatal. Only when building in debug mode. HOT 3
- Linker command
- Loss of data after inflation using gunzip HOT 3
- page www.cryptopp.com/wiki | Obsolete links
- Crypto++ vulnerable to the Marvin Attack HOT 1
- EC2N::DecodePoint can crash if exponents are not in descending order HOT 2
- A security issue in the `ModularSquareRoot` function leads to a DOS attack
- Compile warnings in VS 2022 17.8.0 - stdext::make_checked_array_iterator stdext::make_unchecked_array_iterator beeing deprecated HOT 1
- Memory leak problem!! HOT 2
- Crypto++ needs to support a fixed target HOT 2
- Poly1305 null pointer passed as argument 1 HOT 1
- Django cipher texts not matching Crypto++ cipher texts.
- destructor delete problem with own dialog program with MFC (Unicode/Use MFC in a Shared DLL) VS2015
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cryptopp.