fix: replace deprecated <strstream> with <sstream> in porthopper example#1755
Open
mvanhorn wants to merge 1 commit into
Open
fix: replace deprecated <strstream> with <sstream> in porthopper example#1755mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In
protocol.hpp, replace#include <strstream>with#include <sstream>. Replace eachstd::istrstream is(ptr, len)withstd::istringstream is(std::string(ptr, len)), and eachstd::ostrstream os(data_, N)with a localstd::ostringstream os, followed byos.str().copy(data_, N)(after checkingosstate) so the fixeddata_buffer receives exactly the samesetw-padded bytes as before; no interfaces ofcontrol_requestorframechange, soclient.cppandserver.cppneed no edits and serve as the compile/behavior surface. Graveyard delta vs closed PR #1729: that PR was auto-generated by a bot app and was closed unreviewed with zero comments (the issue author himself asked what happened to it); this plan is a human-authored minimal diff that avoids #1729's rawstd::memcpy(which requires a<cstring>include and risks copying fewer bytes than the buffer on a failed stream) by usingstd::string::copywith explicit stream-state and length checks, and it documents that the on-wire format is unchanged.Why this matters
The C++11 porthopper example includes
<strstream>and usesstd::istrstream/std::ostrstreaminsrc/examples/cpp11/porthopper/protocol.hpp.<strstream>has been deprecated since C++98 and is removed in C++26 per P2867R1, so GCC 16 emits-Wdeprecated-declarationsand#warningnoise at lines 56, 65, 84, 115, and 124, and the example will stop compiling under C++26. The reporter (heitbaum, LibreELEC) hit this building the examples with a GCC 16 toolchain. The fix is to switch the header to<sstream>withstd::istringstream/std::ostringstreamwhile keeping the fixed-width, space-padded wire encoding byte-identical.See #1725.
Testing
Fixes #1725