偶然發現一個奇怪的問題,VS2015 Enterprise版,添加類時,如果類名為ABC,VS彈出如下對話框
,提示:“CodeModel操作失敗。可能無法訪問標記資料庫”。但如果換一個類名則正常。這是VS2015的BUG?哪位安裝相同VS版本的試試,是否也是這樣?
uj5u.com熱心網友回復:
已測驗,無任何問題。控制臺下添加的,MFC沒試。uj5u.com熱心網友回復:
小寫看看......uj5u.com熱心網友回復:
怪了,我也是這種情況!但是設為ABCD就沒有問題.uj5u.com熱心網友回復:
#import can optionally include one or more attributes. These attributes tell the compiler to modify the contents of the type-library headers. A backslash (\) symbol can be used to include additional lines in a single #import statement. For example:#import “test.lib” no_namespace \
rename(“OldName”, “NewName”)
……
The rename attribute
rename("OldName","NewName")
OldName
Old name in the type library
NewName
Name to be used instead of the old name
The rename attribute is used to work around name collision problems. If this attribute is specified, the compiler replaces all occurrences of OldName in a type library with the user-supplied NewName in the resulting header files.
This attribute can be used when a name in the type library coincides with a macro definition in the system header files. If this situation is not resolved, then various syntax errors will be generated, such as C2059 and C2061.
Note The replacement is for a name used in the type library, not for a name used in the resulting header file.
Here is an example: Suppose a property named MyParent exists in a type library, and a macro GetMyParent is defined in a header file and used before #import. Since GetMyParent is the default name of a wrapper function for the error-handling get property, a name collision will occur. To work around the problem, use the following attribute in the #import statement:
rename(“MyParent”,”MyParentX”)
which renames the name MyParent in the type library. An attempt to rename the GetMyParent wrapper name will fail:
rename(“GetMyParent”,”GetMyParentX”)
This is because the name GetMyParent only occurs in the resulting type library header file.
uj5u.com熱心網友回復:
難道是因為類名和檔案名相同了才不行的??uj5u.com熱心網友回復:
可能是因為與ABC Structure重名導致的嗎?但是ABC Structure不是VS2015帶來的新事物啊,老早就有了,為什么只在VS2015 Enterprise版中才出現這個問題呢?哪位裝有Enterprise之外的VS 2015也幫試試看?uj5u.com熱心網友回復:
VS2010 下MFC專案中成功添加 C++ 類 ABCuj5u.com熱心網友回復:
2015以前版本都沒有遇到過這個問題,我的是VS2015 Enterprise版。轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/116865.html
標籤:基礎類
