sh_none is not a member of 'std::basic_filebuf<_Elem,_Traits>'

你。 提交于 2019-12-11 07:17:15

问题


I am trying to use the Microsoft Specific filebuf::sh_none variable to open an fstream in an exclusive mode (another Microsoft specific function). I am getting the above error. I am importing <fstream>. How can I fix this error?

UPDATE: I found this thread, where it was suggested that I try _SH_DENYNO instead. The code compiles, I am testing it now. This doesn't make any sense to me, as this isn't documented in the function.


回答1:


What version of Visual C++ are you using?

The Visual C++ 6 documentation you linked to is the pre-standard version of iostreams, from #include <fstream.h>. It's no longer available, and even in Visual C++ 6.0 was only there for backward compatibility.

Also, _SH_DENYNO is the opposite of exclusive mode. You want _SH_DENYRW to get the same behavior as sh_none. Here is the new documentation: http://msdn.microsoft.com/en-us/library/44cs32f9.aspx, which ends up directing you to http://msdn.microsoft.com/en-us/library/8f30b0db.aspx for details on the third parameter.



来源:https://stackoverflow.com/questions/4435091/sh-none-is-not-a-member-of-stdbasic-filebuf-elem-traits

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!