windows 我如何获得sal.h

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4434198/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:47:33  来源:igfitidea点击:

How do I get sal.h

windowscompiler-constructionsdkheader

提问by Clay

I have been trying to compile a program with minw32, on win7. Every time I try to compile this, I get an error about sal.h missing. I have downloaded both Visual Studio c++ 2010 (Express) and have gotten the Microsoft Win7 SDK. Even after all this, I still haven't found that header file. Is there any place I could download it from?

我一直在尝试在 win7 上用 minw32 编译一个程序。每次我尝试编译它时,我都会收到一个关于缺少 sal.h 的错误。我已经下载了 Visual Studio c++ 2010 (Express) 并获得了 Microsoft Win7 SDK。即使做了这一切,我仍然没有找到那个头文件。有什么地方可以下载吗?

回答by Simon Mourier

It's located in

它位于

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include" (VS 2008)

or

或者

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include" (VS 2010)

or

或者

"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include" (VS 2012)

of course, you may want to adapt to your local setup paths.

当然,您可能希望适应本地设置路径。

回答by nemequ

As the previous answer says, SAL is a Visual Studio thing. IMHO it's a great technology which helps the compiler understand the code so it can emit warnings when you do something wrong. Unfortunately, Microsoft seems to own a patent on it so other compilers can't implement it?. Even if you grab a copy of sal.hfrom your VS install I sincerely doubt it will work with mingw since it will translate the macros into attributes gcc/mingw doesn't understand.

正如前面的答案所说,SAL 是 Visual Studio 的东西。恕我直言,这是一项很棒的技术,可以帮助编译器理解代码,以便在您做错事时发出警告。不幸的是,微软似乎拥有它的专利,所以其他编译器无法实现它?。即使您sal.h从 VS 安装中获取了一份副本,我也真诚地怀疑它是否可以与 mingw 一起使用,因为它会将宏转换为 gcc/mingw 不理解的属性。

I put together a small project called Salieria while back which is basically a portable version of the SAL header that just defines away the SAL macros. You won't get any of the benefits of SAL annotated code, but it should help you get code which uses SAL to compile on other compilers.

不久前,我整理了一个名为Salieri的小项目,它基本上是 SAL 标头的可移植版本,它只是定义了 SAL 宏。您不会获得 SAL 注释代码的任何好处,但它应该可以帮助您获得使用 SAL 在其他编译器上编译的代码。

Sorry to promote my own project here, but I think it could be useful for a lot of people coming across this post.

很抱歉在这里宣传我自己的项目,但我认为它可能对很多看到这篇文章的人有用。