From 3db36c63ca576ccc7f3a09666e59e5671abb7d01 Mon Sep 17 00:00:00 2001 From: Fletcher Dunn Date: Sat, 2 May 2020 13:10:56 -0700 Subject: [PATCH] Move rendering helpers. When linking with Steam, these call ISteamNetworkingUtils functions, and GCC complains if it hasn't seen that class. Even if you don't ever call any of these functions, GCC doesn't like the fact it could not generate the code if you were to do so. Not sure what the spec says, but it feels like Visual Studio's approach makes more sense here. --- include/steam/isteamnetworkingutils.h | 19 +++++++++++++++++++ include/steam/steamnetworkingtypes.h | 19 ------------------- .../steamnetworkingsockets_internal.h | 1 + 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/steam/isteamnetworkingutils.h b/include/steam/isteamnetworkingutils.h index 002be0f..f393e6a 100644 --- a/include/steam/isteamnetworkingutils.h +++ b/include/steam/isteamnetworkingutils.h @@ -180,6 +180,25 @@ protected: ) #endif +/// Utility class for printing a SteamNetworkingIdentity. +/// E.g. printf( "Identity is '%s'\n", SteamNetworkingIdentityRender( identity ).c_str() ); +struct SteamNetworkingIdentityRender +{ + SteamNetworkingIdentityRender( const SteamNetworkingIdentity &x ) { x.ToString( buf, sizeof(buf) ); } + inline const char *c_str() const { return buf; } +private: + char buf[ SteamNetworkingIdentity::k_cchMaxString ]; +}; + +/// Utility class for printing a SteamNetworkingIPAddrRender. +struct SteamNetworkingIPAddrRender +{ + SteamNetworkingIPAddrRender( const SteamNetworkingIPAddr &x, bool bWithPort = true ) { x.ToString( buf, sizeof(buf), bWithPort ); } + inline const char *c_str() const { return buf; } +private: + char buf[ SteamNetworkingIPAddr::k_cchMaxString ]; +}; + /////////////////////////////////////////////////////////////////////////////// // // Internal stuff diff --git a/include/steam/steamnetworkingtypes.h b/include/steam/steamnetworkingtypes.h index 25d2f51..797b344 100644 --- a/include/steam/steamnetworkingtypes.h +++ b/include/steam/steamnetworkingtypes.h @@ -1300,25 +1300,6 @@ inline void GetSteamNetworkingLocationPOPStringFromID( SteamNetworkingPOPID id, /// The POPID "dev" is used in non-production environments for testing. const SteamNetworkingPOPID k_SteamDatagramPOPID_dev = ( (uint32)'d' << 16U ) | ( (uint32)'e' << 8U ) | (uint32)'v'; -/// Utility class for printing a SteamNetworkingIdentity. -/// E.g. printf( "Identity is '%s'\n", SteamNetworkingIdentityRender( identity ).c_str() ); -struct SteamNetworkingIdentityRender -{ - SteamNetworkingIdentityRender( const SteamNetworkingIdentity &x ) { x.ToString( buf, sizeof(buf) ); } - inline const char *c_str() const { return buf; } -private: - char buf[ SteamNetworkingIdentity::k_cchMaxString ]; -}; - -/// Utility class for printing a SteamNetworkingIPAddrRender. -struct SteamNetworkingIPAddrRender -{ - SteamNetworkingIPAddrRender( const SteamNetworkingIPAddr &x, bool bWithPort = true ) { x.ToString( buf, sizeof(buf), bWithPort ); } - inline const char *c_str() const { return buf; } -private: - char buf[ SteamNetworkingIPAddr::k_cchMaxString ]; -}; - /// Utility class for printing a SteamNetworkingPOPID. struct SteamNetworkingPOPIDRender { diff --git a/src/steamnetworkingsockets/steamnetworkingsockets_internal.h b/src/steamnetworkingsockets/steamnetworkingsockets_internal.h index 650d00c..04a8aec 100644 --- a/src/steamnetworkingsockets/steamnetworkingsockets_internal.h +++ b/src/steamnetworkingsockets/steamnetworkingsockets_internal.h @@ -57,6 +57,7 @@ #include "keypair.h" #include #include +#include // for the rendering helpers // Running against Steam? Then we have some default signaling. // Otherwise, we don't