因此,出于某种原因,我认为msclr在运行时没有被使用.这是代码:
#include <stdlib.h>
#include <string.h>
#include <msclr\marshal.h>
#include "stdafx.h"
using namespace System;
using namespace msclr::interop;
int main()
{
const char* message = "Test String to Marshal";
String^ result;
result = marshal_as<String^>(message);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:"C2653:'msclr':不是类或命名空间名称",根本没有任何意义.令我难以置信的是,不仅是我的电脑,还有我尝试使用msclr的任何其他电脑.此外,visual studio没有强调任何内容,因此IDE可以识别名称空间.有人可以帮帮我吗?显然,标题正确定位,因此很多网站已经说明了这种情况.提前致谢.
当我在我的机器上构建它时,显示的第一个错误是你提到的C2653错误.但是,它也会显示一些警告,这些警告可以解决问题的核心.我得到的第一个警告是:
warning C4627: '#include <stdlib.h>': skipped when looking for precompiled header use.
Run Code Online (Sandbox Code Playgroud)
使用预编译头时,.cpp文件中的第一行非常重要
#include "stdafx.h"
Run Code Online (Sandbox Code Playgroud)
一旦我将该行作为.cpp文件的第一行,一切都正确编译.
| 归档时间: |
|
| 查看次数: |
640 次 |
| 最近记录: |