我正在尝试将Python库包装在C ++库周围,而distutils在OS X上对我来说是失败的。这是setup.py中的相关内容:
if sys.platform.startswith("darwin"):
extra_compile_args_setting = ["-std=c++1z", "-stdlib=libc++", "-O3"]
Run Code Online (Sandbox Code Playgroud)
这是相关的输出:
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/x/anaconda/include -arch x86_64 -I/Users/x/anaconda/include -arch x86_64 -I../../cpp_client/libsrc -I../../cpp_client/third_party -I/Users/x/anaconda/include/python3.6m -c navdb_python_client_wrap.cxx -o build/temp.macosx-10.7-x86_64-3.6/navdb_python_client_wrap.o -std=c++1z -stdlib=libc++ -O3
clang++ -bundle -undefined dynamic_lookup -L/Users/x/anaconda/lib -L/Users/x/anaconda/lib -arch x86_64 build/temp.macosx-10.7-x86_64-3.6/navdb_python_client_wrap.o -L../../cpp_client/lib -L/Users/x/anaconda/lib -lnavdb_cpp_client_api -o /Users/x/Development/NavDB/trunk/src/client/lang_clients/python3_client/build/_navdb_python_client.cpython-36m-darwin.so
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed …Run Code Online (Sandbox Code Playgroud) 我想使用std :: map通过使用两个整数作为键查找来存储指向结构的指针,例如:
std::map<int, int, my_struct*> my_map;
Run Code Online (Sandbox Code Playgroud)
理想情况下,我想编写类似于的代码:
struct my_struct* test1 = get_struct_ptr();
my_map[1, 5] = test1;
Run Code Online (Sandbox Code Playgroud)
目前我收到了my_map定义的错误:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/map:524:17:
error: called object type 'my_struct *' is not a function or function pointer
Run Code Online (Sandbox Code Playgroud)
有没有办法用std :: map做到这一点,还是有另一种类型可以处理这个要求?
我有一个类,我需要使线程安全.我试图通过在类中的每个函数的顶部放置一个独特的锁来做到这一点.问题是,只要一个函数调用另一个函数(在此类中),互斥锁似乎相互锁定,尽管它们处于不同的函数中.我怎么能阻止这种情况发生?
一个例子是一个带有get()和set()函数的类,它们在每个函数的开头都使用unique_lock.但是在set()中你想在某个时候调用get(),但是没有set()的互斥锁定get()的互斥锁.但是,如果直接调用,get()中的互斥锁仍然可以工作.