OpenSceneGraph icon indicating copy to clipboard operation
OpenSceneGraph copied to clipboard

'_FPOSOFF' has been deprecated, error C3861: '_FPOSOFF': identifier not found

Open FrankXie05 opened this issue 1 year ago • 1 comments

I am the maintainer of vcpkg and we found above error when we test this port in an internal version of Visual Studio.

This error due to _FPOSOFF' has been completely deprecated after the standard MSVC-PR-132953 .

For fixing this issue: we think bellow code https://github.com/openscenegraph/OpenSceneGraph/blob/2e4ae2ea94595995c1fc56860051410b0c0be605/src/osgPlugins/osga/OSGA_Archive.cpp#L80

could be change to

std::streamoff offset = 0;

Reason: When pos.operator std::streamoff() is called, the std::streampos object pos is actually converted to the std::streamoff type to obtain its offset in the stream. And _FPOSOFF(position) is to get the offset of the fpos_t object position in the stream.

In this code, the calculate the offset of pos relative to position, but because the definition of _FPOSOFF is no longer available, and since the result of _FPOSOFF(position) is the same as pos.operator std::streamoff(). Related PR: https://github.com/microsoft/STL/pull/4606 https://github.com/microsoft/vcpkg/pull/38666

If you have other solotions, please ping me. I will apply it to vcpkg for this issue. :)

FrankXie05 avatar May 10 '24 02:05 FrankXie05

I'm not the author of this particular workaround for prior issues with Win32:

#if ((defined(_YVALS) && !defined(IBMCPP)) || defined(_CPPLIB_VER)) &&
!defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
&& !defined(QNX)

...

#else

And just use the path used by all platforms:

// do the old school streampos <-> streamoff casts inline std::streampos STREAM_POS( const OSGA_Archive::pos_type pos ) { return std::streampos( pos ); }

inline OSGA_Archive::pos_type ARCHIVE_POS( const std::streampos & pos ) { return OSGA_Archive::pos_type( pos ); }

robertosfield avatar May 10 '24 06:05 robertosfield