VS2005 使用错误提示集

1.对于error:cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR'

解决如下:方法1:Press ALT+F7 to open the properties, and navigate to Configuration Properties > General. Switch Character Set to "Use Multi-Byte Character Set".

                     方法2:Indicate that the string literal, in this case "Hello world!" is of a specific encoding. This can be done through either prefixing it with L, such as L"Hello world!", or surrounding it with the generic _T("Hello world!") macro. The latter will expand to the L prefix if you are compiling for unicode (see #1), and nothing (indicating multi-byte) otherwise.

2    DirectSound      error C2065: ' DSBCAPS_CTRLDEFAULT' : undeclared identifier

A:The DX SDK documents are your friend. A quick search turned up this bit:

The DSBCAPS_CTRLDEFAULT flag is no longer supported. This flag was defined as DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY. By specifying only the flags you need, you cut down on unnecessary resource usage.

3.

C语言头文件的多重包含与重复包含
 
 

一.头文件的多重包含

对于同一个.h文件,如果在多个.h文件所引用,而这多个.h文件又需要在同一个.cpp或者文件用引用时,这就涉及到C语言的头文件的多重包含。

例:有如下几个文件:

file1.h:  
   
  #ifndef   FILE1_H  
  #define   FILE1_H  

  #i nclude   "iostream.h"  
  ...  
  ...  
  ...  
  #endif  
   
  file2.h  
  #ifndef   FILE2_H  
  #define   FILE2_H  

  #i nclude   "file1.h"  
  #i nclude   "iostream.h"  
  ...  
  ...  
  ...  

#endif

那么对于以上两个文件的重复包含不对导致编译错误。

也可以在每个文件的开始写出:#pragma once,保证本文件中的内容只被使用一次。

详细地说:如果有以下几个头文件及其包含关系为:

File1.h,file2.h,file3.h,file4.h,file5.hmain.cpp

那么:file3.h包含file1.h,file2.hfile4.h包含file1.h,file2.hfile5.h包含file3.h,file4.h。这样就会导致在file5中对file1file2的重复包含,编译时就会报错。

解决方法:

1:利用 #ifndef

           #define

        #endif

         即每个文件在定义时都写成如下形式(以file1.h为例):

             #ifndef H_FILE1

             #define H_FILE1

                    #i nclude

             #i nclude

              …..

                     #endif

File3.h:   #ifndef H_FILE3

             #define H_FILE3

                     #i nclude

             #i nclude

                     #inlcude”file1.h”

                     #i nclude”file2.h”

                    …..

                     #endif

方法二:在每个文件的头部定义:#pragma once  (用于说明本文件中的内容只使用一次)

  例:fiel1.h:

                     #pragma once

                     #i nclude

             #i nclude

                           …..

         File3.h:

                   #pragma once

                   #i nclude

                   #i nclude

                   #i nclude”file1.h”

                     …..

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10697500/viewspace-541319/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10697500/viewspace-541319/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值