我正在编译本教程中的简单应用程序:https: //www.johnlamp.net/cmake-tutorial-1-getting-started.html(只是main.cc,ToDo.cc和ToDo.h文件).
我安装了Visual Studio 2015,当我使用它的生成器时,VS项目成功生成:
PS C:\data\OtherTech\cmaketest\build> cmake "Visual Studio 14 2015" ..
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用"NMake Makefiles"或"Unix Makefiles"生成器:
PS C:\data\OtherTech\cmaketest\build> cmake "NMake Makefiles" ..
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
> PS C:\data\OtherTech\cmaketest\build> cmake -G "NMake Makefiles" ..
-- The C compiler identification is MSVC 19.0.23026.0
-- The CXX compiler identification is MSVC 19.0.23026.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- broken
CMake Error at C:/Users/user1/Desktop/Apps/cmake-3.4.0-win32-x86/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61 ( …Run Code Online (Sandbox Code Playgroud) 我有以下文件的数据库:
> db.bios.find({"name.first":"James"}).pretty()
{
"_id" : 9,
"name" : {
"first" : "James",
"last" : "Gosling"
},
"birth" : ISODate("1955-05-19T04:00:00Z"),
"contribs" : [
"Java",
"C",
"Scala",
"UNIX"
],
"awards" : [
{
"award" : "The Economist Innovation Award",
"year" : 2002,
"by" : "The Economist"
},
{
"award" : "Officer of the Order of Canada",
"year" : 2007,
"by" : "Canada"
},
{
"award" : "nobel",
"by" : "Stockholm"
},
{
"award" : "nobel2",
"by" : "Stockholm"
},
{
"award" …Run Code Online (Sandbox Code Playgroud) 我正在使用moq并想模拟一个接受out参数的方法:
protected void GetDataRow(string id, out DataRow dataRow)
Run Code Online (Sandbox Code Playgroud)
这是我试过的:
dataMock.Protected().Setup("GetDataRow", ItExpr.IsAny<string>(), ItExpr.IsAny<DataRow>());
Run Code Online (Sandbox Code Playgroud)
但是,它返回:
System.ArgumentException : Member DataManager.GetDataRow does not exist.
Run Code Online (Sandbox Code Playgroud)
如果我不改变dataRow参数out,一切都按预期工作.
在这种情况下我应该如何创建模拟?
在node.js中,异步函数具有回调函数,但是只有部分函数将err参数传递给该函数.例如,fs.writeFile有err作为参数
fs.writeFile('message.txt', 'Hello Node', function (err) {
if (err) throw err;
console.log('It\'s saved!');
});
Run Code Online (Sandbox Code Playgroud)
但fs.watchfile没有
fs.watchFile('message.text', function (curr, prev) {
console.log('the current mtime is: ' + curr.mtime);
console.log('the previous mtime was: ' + prev.mtime);
});
Run Code Online (Sandbox Code Playgroud)
第一个问题是为什么有些异步函数在回调中有错误的参数,有些则没有?我们怎么处理那些没有的错误呢?
另外,就同步函数而言,它们是否都发出"错误"事件,我们可以订阅并以这种方式处理错误?
var rs = fs.createReadStream("C:\\Temp\\movie.mp4");
rs.on('error', function(err) {
console.log('!error: ', err);
});
Run Code Online (Sandbox Code Playgroud)
最后一个问题:大多数同步函数在名称中都有Sync ...为什么createReadStream没有?
谢谢!