Skip to content

Commit db3a5f2

Browse files
Arcmantis/warning deprecate WidenFilename (#2398)
* Added OPENEXR_DEPRECATED to function WidenFilename indicating its future removal Signed-off-by: Aries Moczar <arcmantis@protulae.com> * Disable warnings of deprecated WidenFilename in unit-tests Signed-off-by: Aries Moczar <arcmantis@protulae.com> * Corrected compiler check from _WIN32 to _MSC_VER. Added additional conditions for __clang__ and __GNUC__. Signed-off-by: Aries Moczar <arcmantis@protulae.com> * Added TODO comments indicating pragmas disabling deprecation-warnings should be removed once WidenFilename is removed. Signed-off-by: Aries Moczar <arcmantis@protulae.com> * Tightened pragmas around WidenFilename to be more precise when disabling deprectation warnings Signed-off-by: Aries Moczar <arcmantis@protulae.com> --------- Signed-off-by: Aries Moczar <arcmantis@protulae.com> Co-authored-by: Cary Phillips <cary@ilm.com>
1 parent 5d6e875 commit db3a5f2

3 files changed

Lines changed: 69 additions & 1 deletion

File tree

src/lib/OpenEXR/ImfMisc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ int getChunkOffsetTableSize (const Header& header);
438438
// Convert a UTF-8 filename to a wide string (for example for Windows APIs).
439439
//
440440

441+
OPENEXR_DEPRECATED ("To be removed in future releases.")
441442
IMF_EXPORT
442443
std::wstring WidenFilename (const char* filename);
443444

src/test/OpenEXRTest/TestUtilFStream.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,26 @@ inline void
103103
OpenStreamWithUTF8Name (
104104
StreamType& is, const char* filename, std::ios_base::openmode mode)
105105
{
106-
# ifdef _WIN32
106+
107+
# ifdef _WIN32
108+
109+
// TODO: Remove pragmas for pushing/popping deprecation warnings when WidenFilename is removed from API
110+
# ifdef _MSC_VER
111+
# pragma warning(push)
112+
# pragma warning(disable: 4996)
113+
# elif defined(__clang__) || defined(__GNUC__)
114+
# pragma GCC diagnostic push
115+
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
116+
# endif
117+
107118
std::wstring wfn = OPENEXR_IMF_INTERNAL_NAMESPACE::WidenFilename (filename);
119+
120+
# ifdef _MSC_VER
121+
# pragma warning(pop)
122+
# elif defined(__clang__) || defined(__GNUC__)
123+
# pragma GCC diagnostic pop
124+
# endif
125+
108126
# ifdef USE_WIDEN_FILEBUF
109127
using CharT = typename StreamType::char_type;
110128
using TraitsT = typename StreamType::traits_type;

src/test/OpenEXRTest/testExistingStreams.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,24 @@ MMIFStream::MMIFStream (const char fileName[])
127127
, _length (0)
128128
{
129129
#ifdef _WIN32
130+
131+
// TODO: Remove pragmas for pushing/popping deprecation warnings when WidenFilename is removed from API
132+
# ifdef _MSC_VER
133+
# pragma warning(push,0)
134+
# pragma warning(disable: 4996)
135+
# elif defined(__clang__) || defined(__GNUC__)
136+
# pragma GCC diagnostic push
137+
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
138+
# endif
139+
130140
const std::wstring fileNameWide = WidenFilename (fileName);
141+
142+
# ifdef _MSC_VER
143+
# pragma warning(pop)
144+
# elif defined(__clang__) || defined(__GNUC__)
145+
# pragma GCC diagnostic pop
146+
# endif
147+
131148
try
132149
{
133150
_f = CreateFileW (
@@ -1093,7 +1110,23 @@ testExistingStreamsUTF8 (const std::string& tempDir)
10931110
{
10941111
cout << "writing";
10951112
#ifdef _WIN32
1113+
1114+
// TODO: Remove pragmas for pushing/popping deprecation warnings when WidenFilename is removed from API
1115+
# ifdef _MSC_VER
1116+
# pragma warning(push,0)
1117+
# pragma warning(disable: 4996)
1118+
# elif defined(__clang__) || defined(__GNUC__)
1119+
# pragma GCC diagnostic push
1120+
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1121+
# endif
1122+
10961123
_wremove (WidenFilename (outfn.c_str ()).c_str ());
1124+
1125+
# ifdef _MSC_VER
1126+
# pragma warning(pop)
1127+
# elif defined(__clang__) || defined(__GNUC__)
1128+
# pragma GCC diagnostic pop
1129+
# endif
10971130
#else
10981131
remove (outfn.c_str ());
10991132
#endif
@@ -1144,7 +1177,23 @@ testExistingStreamsUTF8 (const std::string& tempDir)
11441177
cout << endl;
11451178

11461179
#ifdef _WIN32
1180+
1181+
// TODO: Remove pragmas for pushing/popping deprecation warnings when WidenFilename is removed from API
1182+
# ifdef _MSC_VER
1183+
# pragma warning(push,0)
1184+
# pragma warning(disable: 4996)
1185+
# elif defined(__clang__) || defined(__GNUC__)
1186+
# pragma GCC diagnostic push
1187+
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1188+
# endif
1189+
11471190
_wremove (WidenFilename (outfn.c_str ()).c_str ());
1191+
1192+
# ifdef _MSC_VER
1193+
# pragma warning(pop)
1194+
# elif defined(__clang__) || defined(__GNUC__)
1195+
# pragma GCC diagnostic pop
1196+
# endif
11481197
#else
11491198
remove (outfn.c_str ());
11501199
#endif

0 commit comments

Comments
 (0)