openscenegraph / OpenSceneGraph

OpenSceneGraph git repository
http://www.openscenegraph.org
Other
3.25k stars 1.42k forks source link

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

Open FrankXie05 opened 6 months ago

FrankXie05 commented 6 months ago

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. :)

robertosfield commented 6 months ago

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 ); }