描述:
我写了一个带窗口的ATL控件,在使用的时候使用#import "******.tlb" nonamespace 导入tlb文件,但始终找不到该定义,但在*.tlh中是有的,
定义:
IxxxPtr dd;
错误提示:d:\Test\RichBmp\RichBmpTest\RichBmpTestDlg.h(52): error C2146: syntax error : missing ';' before identifier 'dd'
解决方案1:
可以试试不用nonamespace
#import "***\**.tlb" rename_namespace("***")
using namespace ***;
接口名写错了?
解决方案3:如果不是namespace的问题,那就只能是头文件包含顺序的问题了
解决方案4: 检查一下no namespace是否起了作用,参考:
http://support.microsoft.com/kb/269194/en-us
If you encounter errors that are due to missing type definitions, check the comments at the head of the .TLH to see which dependent type libraries may need to be imported first. Likely errors are syntax errors (for example, C2143, C2146, C2321), C2501 (missing decl-specifiers), or C2433 ('inline' not permitted on data declaration) while compiling the .TLI file.
是否少了#include <COMDEF.H> ?
解决方案6:一般是生成的头文件的路径问题,或者是以前的头文件没有更新,或者是引用错了头文件-___- 没猜对的话当偶没说过^^b