C ++非法索引,间接不允许错误

时间:2017-06-12 13:51:19

标签: c++ mongodb

我有以下Mongo C ++程序。

#include <cstdint>
#include <iostream>
#include <vector>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>

using bsoncxx::builder::stream::close_array;
using bsoncxx::builder::stream::close_document;
using bsoncxx::builder::stream::document;
using bsoncxx::builder::stream::finalize;
using bsoncxx::builder::stream::open_array;
using bsoncxx::builder::stream::open_document;

    int main(int argc, char** argv)
    {    
        // Making a connection to Mongo
        mongocxx::instance instance();
        mongocxx::client client(mongocxx::uri());

        // Access a database
        mongocxx::database db = client["results"];

        return 0;
    }

此行mongocxx::database db = client["results"];提供以下错误消息:

illegal index, indirection not allowed.

我究竟做错了什么?我在Windows 10 64bit上使用MSBuild进行编译。

完整的错误消息是:

Build started 6/12/2017 5:01:21 PM.
Project "F:\Projects\Mongo\attempt_2\testing\build\ALL_BUILD.vcxproj" on node 1 (default targets).
Project "F:\Projects\Mongo\attempt_2\testing\build\ALL_BUILD.vcxproj" (1) is building "F:\Projects\Mongo\attemp
t_2\testing\build\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).
PrepareForBuild:
  Creating directory "x64\Debug\ZERO_CHECK\".
  Creating directory "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\".
InitializeBuildStatus:
  Creating "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
  Checking Build System
  CMake does not need to re-run because F:/Projects/Mongo/attempt_2/testing/build/CMakeFiles/generate.stamp is
  up-to-date.
FinalizeBuildStatus:
  Deleting file "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
  Touching "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
Done Building Project "F:\Projects\Mongo\attempt_2\testing\build\ZERO_CHECK.vcxproj" (default targets).

Project "F:\Projects\Mongo\attempt_2\testing\build\ALL_BUILD.vcxproj" (1) is building "F:\Projects\Mongo\attemp
t_2\testing\build\testapp.vcxproj" (3) on node 1 (default targets).
PrepareForBuild:
  Creating directory "testapp.dir\Debug\".
  Creating directory "F:\Projects\Mongo\attempt_2\testing\build\Debug\".
  Creating directory "testapp.dir\Debug\testapp.tlog\".
InitializeBuildStatus:
  Creating "testapp.dir\Debug\testapp.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
  Building Custom Rule F:/Projects/Mongo/attempt_2/testing/src/CMakeLists.txt
  CMake does not need to re-run because F:/Projects/Mongo/attempt_2/testing/build/CMakeFiles/generate.stamp is
  up-to-date.
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x64\CL.ex
  e /c /IF:\Projects\Mongo\attempt_2\testing\src\..\..\installed_mongocxx\include\mongocxx\v_noabi /IF:\Project
  s\Mongo\attempt_2\testing\src\..\..\installed_mongocxx\include\bsoncxx\v_noabi /IF:\Softwares\Libraries\Boost
  \boost_1_64_0 /Zi /nologo /W3 /WX- /diagnostics:classic /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debu
  g\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"testapp.dir\D
  ebug\\" /Fd"testapp.dir\Debug\vc141.pdb" /Gd /TP /errorReport:queue F:\Projects\Mongo\attempt_2\testing\src\t
  est.cpp
  test.cpp
F:\Projects\Mongo\attempt_2\testing\src\test.cpp(35): error C2107: illegal index, indirection not allowed [F:\P
rojects\Mongo\attempt_2\testing\build\testapp.vcxproj]
Done Building Project "F:\Projects\Mongo\attempt_2\testing\build\testapp.vcxproj" (default targets) -- FAILED.

Done Building Project "F:\Projects\Mongo\attempt_2\testing\build\ALL_BUILD.vcxproj" (default targets) -- FAILED
.


Build FAILED.

"F:\Projects\Mongo\attempt_2\testing\build\ALL_BUILD.vcxproj" (default target) (1) ->
"F:\Projects\Mongo\attempt_2\testing\build\testapp.vcxproj" (default target) (3) ->
(ClCompile target) ->
  F:\Projects\Mongo\attempt_2\testing\src\test.cpp(35): error C2107: illegal index, indirection not allowed [F:
\Projects\Mongo\attempt_2\testing\build\testapp.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.79

0 个答案:

没有答案