VS2010编译的时候碰到winnt.h问题

http://hagejid.blog.51cto.com/141754/294797

今天心血来潮,到微“软”那下了个VS2010玩玩。装好了就随便做个工程,结果编译的时候出来几个错误,全是在winnt.h里边。

 
 
  1. ------ Rebuild All started: Project: 123, Configuration: Debug Win32 ------  
  2.   stdafx.cpp  
  3. c:\program files\microsoft sdks\windows\v7.0a\include\winnt.h(290): error C2146: syntax error : missing ';' before identifier 'PVOID64' 
  4. c:\program files\microsoft sdks\windows\v7.0a\include\winnt.h(290): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
  5. c:\program files\microsoft sdks\windows\v7.0a\include\winnt.h(8992): error C2146: syntax error : missing ';' before identifier 'Buffer' 
  6. c:\program files\microsoft sdks\windows\v7.0a\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
  7. c:\program files\microsoft sdks\windows\v7.0a\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
  8. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== 

然后又是搜索大法,以这些信息搜索,找谁碰到这个问题。结果在微软的网站上看到了一条信息。

 

 
 
  1. I built a new project to start the porting of an application written with CV6++, but the project stopped with the following errore just after few modifications to stdafx.h and the main include icarus2010.h.  
  2.  
  3.  
  4.  
  5. 1>------ Build started: Project: Icarus2010, Configuration: Debug Win32 ------  
  6. 1>Build started 04/11/2009 16.51.46.  
  7. 1>_PrepareForBuild:  
  8. 1> Touching "Debug\Icarus2010.unsuccessfulbuild".  
  9. 1>ClCompile:  
  10. 1> stdafx.cpp  
  11. 1>c:\programmi\microsoft sdks\windows\v7.0a\include\winnt.h(290): error C2146: syntax error : missing ';' before identifier 'PVOID64' 
  12. 1>c:\programmi\microsoft sdks\windows\v7.0a\include\winnt.h(290): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
  13. 1>c:\programmi\microsoft sdks\windows\v7.0a\include\winnt.h(8992): error C2146: syntax error : missing ';' before identifier 'Buffer' 
  14. 1>c:\programmi\microsoft sdks\windows\v7.0a\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
  15. 1>c:\programmi\microsoft sdks\windows\v7.0a\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
  16. 1>c:\programmi\microsoft sdks\windows\v7.0a\include\exdisp.h(842): error C2061: syntax error : identifier 'SHANDLE_PTR' 
  17. 1>  
  18. 1>Build FAILED.  
  19. 1>  
  20. 1>Time Elapsed 00:00:01.93  
  21. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========  
  22.  
  23. The modifications in the stdafx were  
  24.  
  25. #pragma warning(disable: 4786)  
  26. #pragma warning (disable:4996)  
  27. #pragma warning (disable:4244)  
  28. #pragma warning (disable:4189)  
  29. #pragma warning (disable:4100)  
  30.  
  31. and the modifications in the main inlcude were some include files from the VC6++ application. For a while the new project worked!   
  32.  详细信息 (展开) Product Language  
  33. EnglishVersion  
  34. Visual Studio 2010 Beta 2Operating System  
  35. Windows XP  
  36. Operating System Language  
  37.  
  38. ItalianSteps to Reproduce  
  39. unknownActual Results  
  40. unknownExpected Results  
  41. soon      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey. [Details]   
  42.  
  43.    
  44. ///  
  45.     
  46. 由 Microsoft 在 2009/11/5 1:29 发送   
  47. Thank you for your feedback, We are currently reviewing the issue you have submitted.   
  48. 由 Microsoft 在 2009/11/8 20:41 发送   
  49. Thanks for reporting this issue.   
  50.  
  51. In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.  
  52.  
  53. Please provide us with a demo zipped project file so that we can conduct further research.  
  54.  
  55. It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 7 days, we will close this issue.  
  56.  
  57. Thanks again for your efforts and we look forward to hearing from you.  
  58.  
  59. Visual Studio Product Team  
  60.  
  61. 由 Microsoft 在 2009/11/9 11:54 发送   
  62. Hi -   
  63.  
  64. Do you have the DirectX SDK installed on the machine? We have seen some cases where the DirectX SDK installer modifies the Visual Studio include path and puts the DirectX SDK entries first. This causes the build to use DirectX versions of some files that are a different version that the files in the Visual Studio SDK.  
  65.  
  66. Try changing the order of include directories in VS so the DirectX SDK entries are last. That may solve the problem.  
  67.  
  68. Mike Robinson  
  69. Program Manager  
  70. Windows SDK Team  

有个家伙也碰到了这个问题。微软的回答是,你可能装了DIRECTX SDK,你到包含目录设置把DX SDK的目录往后移就可以了。

第一次用不熟这东西,只好以“winint.h”为关键字找,结果从网上找到一个在VS2005设置DX SDK的。

 

 
 
  1. 解决方法:在winnt.h中加上以下语句  
  2.  
  3. #define POINTER_64 __ptr64  
  4.  
  5. typedef void *PVOID;  
  6. typedef void * POINTER_64 PVOID64;  
  7.  
  8. 个人认为最好不去改winnt.h.  
  9. 有时需要要调整include文件夹的顺序来解决问题,platform SDK中的winnt.h  
  10. DDK中的,vc6.0 自带的winnt.h有多个。 dxsdk 中的这些所用到的winnt.h版本不同。  
  11.  
  12. 通过调整IDE 工具-> 选项-> 项目vc++目录;包含文件include 的顺序来解决这类问题  
  13. 使dxsdk需要的winnt.h所在文件夹在最上面。  
  14.  

 

 
 
  1. DirectShow 在VS2005中环境配置  
  2. 先介绍系统环境:  
  3. XP Professional sp2  
  4. visual studio 2005 version 8.0.50727.42  
  5. DirectX 9.0(9.0b) SDK Update - (Summer 2003)   
  6.  
  7.  
  8. 首先,就是编译baseclasses,什么是baseclasses?打开你的dx的sdk安装目录,例如:  
  9. D:\DX90SDK\Samples\C++\DirectShow\  
  10. 这里就有一个叫baseclasses的工程,为安全起见,请先备份此工程。   
  11.  
  12. 1,双击baseclasses.sln打开,提示我们需要转换工程,按提示转换就是了,编译  
  13. 提示错误:  
  14. 1>D:\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64' 
  15. 1>D:\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
  16. 1>D:\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C2146: syntax error : missing ';' before identifier 'Buffer' 
  17. 1>D:\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
  18. 1>D:\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
  19. 1>d:\DX90SDK\Samples\C++\DirectShow\BaseClasses\ctlutil.h(278) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int第一类问题的解决:错误发生在:operator=(LONG);函数定义中,这是因为在VC6中,如果没有显示的指定返回值类型,编译器将其视为默认整 形;但是vs2005不支持默认整形,解决这个问题不能修改每个没有显示指示返回值类型的函数地方,可以用wd4430来解决;具体的在工程选项中的c+ +/Command Line中添加/wd4430即可。   
  20.  
  21.  
  22. 2,在Tools->Options->Projects and solutions->vc++ directories->show directories for里选择include files  
  23. 然后增加  
  24. D:\DX90SDK\Include  
  25. D:\DX90SDK\Samples\C++\DirectShow\BaseClasses  
  26. D:\DX90SDK\Samples\C++\Common  
  27. 可能会问题依旧,调整一下include files的顺序吧,把他们都放在最后,例如我的环境:  
  28. $(VCInstallDir)include  
  29. $(VCInstallDir)atlmfc\include  
  30. $(VCInstallDir)PlatformSDK\include  
  31. $(FrameworkSDKDir)include  
  32. D:\DX90SDK\Include  
  33. D:\DX90SDK\Samples\C++\DirectShow\BaseClasses  
  34. D:\DX90SDK\Samples\C++\Common  
  35. 然 后在project->BaseClasses properties->configuration->C/C++ -> General->Additional Include Directories里面的内容(.,..\..\..\..\include)删掉,重新编译,PVOID64的错误消失,原因如下:  
  36. POINTER_64 是一个宏,在64位编译下起作用,它包含在SDK目录下的BASETSD.H中(Microsoft Visual Studio 8\VC\PlatformSDK\Include\basetsd.h(23):#define POINTER_64 __ptr64),但DXSDK自己也带了一个basetsd.h,里面没有定义POINTER_64,从而导致出错,只需要改变include files的优先级即可。当然,也可以改写winnt.h中的代码,在下面这两行:typedef   void   *PVOID;     
  37. typedef   void   *POINTER_64   PVOID64;  
  38. 之前增加一行:  
  39. #define   POINTER_64   __ptr64   
  40.  
  41. 3,到目前为止,还剩下:  
  42. BaseClasses\ctlutil.h(278) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
  43. 这个错误,解决方法如下:  
  44. 打开project->BaseClasses properties->configuration->C/C++ ->Command Line,增加/wd4430选项。  
  45. 4, 接着编译,提示error C2065: 'Count' : undeclared identifier等等错误,这个是微软的历史遗留问题了,C++标准语法的问题,因为在之前在for循环内定义的变量可以在for之外的地方使用,即 在第一个forfor(int i,...),以后的for再使用i不必再声明,解决方法也很简单,打开project->BaseClasses properties->configuration->C/C++->Language->Force Comformance in For Loop Scrope设置为No即可。当然,也可以手动改代码,增加一个声明就是了。   
  46.  
  47. 经过上面几个步骤,应该是可以顺利编译了,对于其它版本的工程,照样设置就可以了,总共编译出下面4个文件备用:  
  48. BaseClasses\Debug\strmbasd.lib  
  49. BaseClasses\Debug_Unicode\strmbasd.lib  
  50. BaseClasses\Release\STRMBASE.lib  
  51. BaseClasses\Release_UnicodeSTRMBASE.lib   
  52.  
  53. 在lib里面加入   
  54.  
  55. commctrl.lib   
  56. coredll.lib   
  57. strmiids.lib   
  58. strmbase.lib   
  59. uuid.lib   
  60. ole32.lib   
  61. commdlg.lib   
  62.  
  63. 你或许需要在Tools->Options->Projects and solutions->vc++ directories->show directories for->library files里把它们加进去。  
  64. 赶快编译DX90SDK\Samples\C++\DirectShow\Players\PlayDMO工程试试看吧。   
  65.  
  66.  
  67. 以上资料整理自下面3个blog,一并列出:  
  68. DirectShow在VS2005中PVOID64问题和配置问题   
  69. http://www.cnblogs.com/RunOnTheWay/archive/2008/01/17/1043705.html  
  70. DirectShow 在VS2005中环境配置  
  71. http://blog.cnii.com.cn/?uid-75821-action-viewspace-itemid-24418  
  72. Some DirectShow Samples Break in Visual Studio 2005  
  73. http://blogs.msdn.com/mikewasson/archive/2005/05/23/some-directshow-samples-break-in-visual-studio-2005.aspx  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值