How do I get sal.h

本小妞迷上赌 提交于 2019-12-04 00:49:43

问题


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?


回答1:


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.




回答2:


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.h from your VS install I sincerely doubt it will work with mingw since it will translate the macros into attributes gcc/mingw doesn't understand.

I put together a small project called Salieri a 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.

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



来源:https://stackoverflow.com/questions/4434198/how-do-i-get-sal-h

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