小编Q12*_*123的帖子

在Xcode,mac中找不到gmp.h文件错误

gmp-6.0.0a.tar.xzusr/local目录中下载了文件并解压缩(tar).随着人们说,我输入./configure,make,make checksudo make installgmp-6.0.0目录中.安装似乎很好.但是,当我试图像这样测试

#include <stdio.h>
#include <gmp.h>
#include <gmpxx.h>


int main(int argc, const char * argv[])
{

    // insert code here...
    printf("Hello, World!\n");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

它有错误,gmp.h找不到文件.我添加-lgmp到Other Linker Flags但不起作用.

我不知道如何处理这类问题.有人可以帮忙吗?


谢谢Dietrich Epp.现在我没有找到gmp.h文件的错误,但是我找不到gmpxx.h文件.我不知道为什么..

有什么建议吗?

c c++ macos xcode gmp

5
推荐指数
2
解决办法
5413
查看次数

C ++使用promise从线程返回多个值,将来吗?

我想做的是从每个线程返回一个值。但是,它具有此异常消息。

libc++abi.dylib: terminating with uncaught exception of type std::__1::future_error: Operation not permitted on an object without an associated state.
Run Code Online (Sandbox Code Playgroud)

代码看起来像这样。

vector<thread> t;
promise<class_name> promises;
vector<future<class_name>> futures;

for(int i = 0; i < NumberOfThreads; i++)
{
    futures.push_back(promises.get_future());
    t.push_back(thread(MyFunction ,i , pointList, std::move(promises)));
}
Run Code Online (Sandbox Code Playgroud)

MyFunction看起来像这样。

void MyFunction(int index, const vector<Point>& pointList, promise<class_name>&& p)
{
....
p.set_value(classObj);
}
Run Code Online (Sandbox Code Playgroud)

如果使用线程,则可以正常工作而不会出现异常消息。

有解决这个问题的主意吗?

c++ multithreading future promise c++11

2
推荐指数
1
解决办法
1818
查看次数

ML 中警告和类型的含义

fun a(list) = 
   let
   val num = length(hd(list))
   fun inner(list) = 
      if num = length(hd(list)) then
         if tl(list) = nil then true
         else inner(tl(list))
      else false
   in
   if length(hd(list))-1 = length(tl(list)) then inner(tl(list))
   else false
   end;
Run Code Online (Sandbox Code Playgroud)

这是 ml 代码,我收到了此警告和类型。

stdIn:6.16 Warning: calling polyEqual
val a = fn : ''a list list -> bool
Run Code Online (Sandbox Code Playgroud)

我不明白警告。它出现的原因和类型。''a为什么它有两个'?''?'a list list 和''a list list 有什么区别?

sml

1
推荐指数
1
解决办法
1913
查看次数

标签 统计

c++ ×2

c ×1

c++11 ×1

future ×1

gmp ×1

macos ×1

multithreading ×1

promise ×1

sml ×1

xcode ×1