小编abe*_*ier的帖子

CMAKE_SYSTEM_NAME空白?

我正在尝试为Linux编译(使用Generator Eclipse CDT4 - Ninja)但是当我正在检查${CMAKE_SYSTEM_NAME}CMakeLists.txt,我得到的只是空白.

在哪些情况下使用此变量有效?

使用Debian Testing的cmake 3.02.

cmake

9
推荐指数
2
解决办法
4225
查看次数

通过std :: function包装重载函数

我有一个重载函数,我想传递包裹在std :: function中.GCC4.6没有找到"匹配功能".虽然我在这里找到了一些问题,但答案并不像我希望的那样清晰.有人可以告诉我为什么下面的代码不能扣除正确的重载以及如何(优雅地)解决它?

int test(const std::string&) {
    return 0;
}

int test(const std::string*) {
    return 0;
}

int main() {
    std::function<int(const std::string&)> func = test;
    return func();
}
Run Code Online (Sandbox Code Playgroud)

c++ overloading c++11

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

找不到difference_type

当我尝试std::distance在gcc 4.7下使用自定义迭代器时,它抱怨没有找到difference_type.我遗憾地不知道它为什么会失败.

#include <iterator>

class nit {
public:
    typedef int difference_type;
};

int main() {
  const nit test1;
  std::distance( test1, test1 );
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

给出错误:

/usr/include/c++/4.7/bits/stl_iterator_base_funcs.h:114:5: error: no type named ‘difference_type’ in ‘struct std::iterator_traits<nit>’

c++ gcc gcc4.7

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

在 Alpine 中找不到运行时/cgo

alpine:edge我安装的容器中,通过

RUN apk add --no-cache musl-dev go
Run Code Online (Sandbox Code Playgroud)

那我试着跑go get github.com/golang/protobuf/protoc-gen-go

这会导致错误消息:

go: finding github.com/golang/protobuf/protoc-gen-go latest
go: finding github.com/golang/protobuf v1.3.1
go: downloading github.com/golang/protobuf v1.3.1
go: extracting github.com/golang/protobuf v1.3.1
# github.com/golang/protobuf/protoc-gen-go
loadinternal: cannot find runtime/cgo
protoc-gen-go: program not found or is not executable
Run Code Online (Sandbox Code Playgroud)

现在查看代码,它失败了ctxt.PackageFile[name]

我双重检查,虽然,这两个/usr/lib/go/pkg/tool/linux_amd64/cgo/usr/lib/go/pkg/linux_amd64/runtime/cgo.a都存在。

应该按照go env以下顺序排列:

GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g …
Run Code Online (Sandbox Code Playgroud)

go alpine-linux

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

计划错误:尚未使用 Cloud Resource Manager API

当我尝试跑步时

steps:
- id: Plan Terraform
  name: hashicorp/terraform:light
  args:
  - plan
Run Code Online (Sandbox Code Playgroud)

在 Cloud Build 中,我收到错误:

Error: Error reading Project Service foo/cloudbuild.googleapis.com: googleapi: Error 403: Cloud Resource Manager API has not been used in project 123456789 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=123456789 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured
Run Code Online (Sandbox Code Playgroud)

由于相同的 terraform 定义正在我的本地计算机上运行,​​我认为错误消息有点误导,它实际上是一个凭据问题。

根据 Google Cloud 文档,我应用了以下内容:

resource "google_project_iam_binding" "cloudbuild" …
Run Code Online (Sandbox Code Playgroud)

google-cloud-platform terraform devops terraform-provider-gcp google-cloud-build

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

缺少std :: front和std :: back

C++ 11中是否存在原因std::front并且std::back不存在?有std::beginstd::end如此对我来说,具有相当的有关于实际情况下才有意义.

c++ c++11

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

CountDownLatch等价物

对于某些并发编程,我可以使用Java的CountDownLatch概念.是否存在C++ 11的等价物或者在C++中调用该概念的内容?

我想要的是一旦计数达到零就调用一个函数.

如果还没有,我会写一个类如下的类:

class countdown_function {
public:
  countdown_function( size_t count );
  countdown_function( const countdown_function& ) = default;
  countdown_function( countdown_function&& ) = default;
  countdown_function& operator=( const countdown_function& ) = default;
  countdown_function& operator=( countdown_function&& ) = default;
  // Callback to be invoked
  countdown_function& operator=(std::function<void()> callback);
  countdown_function& operator--();
private:
  struct internal {
    std::function<void()> _callback;
    size_t _count;
    // + some concurrent handling
  };
  // Make sure this class can be copied but still references
  // same state
  std::shared_ptr<internal> _state;
};
Run Code Online (Sandbox Code Playgroud)

类似的东西已经可以在任 …

c++ java c++11

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

在Build目录中输出SCons

我正在尝试修改我的SCons文件,以便将生成的文件放入构建目录中.最初我虽然VariantDir可能是一个选项,但从我阅读的所有内容和示例来看,它并没有做我想要的.

有没有简单的方法强制SCons将输出放在某个目录中而不必重写所有的源和脚本?

scons

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

禁用详细信息/摘要

当我将新details标签与 a 结合使用时,summary我想禁用生成的输入。我认为

<details open disabled>
Run Code Online (Sandbox Code Playgroud)

可以做到这一点,但遗憾的是它不起作用。

如何禁用详细信息元素?

html javascript css

6
推荐指数
2
解决办法
3609
查看次数

有哪些不同类型的runfiles

DefaultInfo的文档中,我们现在可以返回3种不同的"类型"的runfiles:

runfiles
data_runfiles
default_runfiles
Run Code Online (Sandbox Code Playgroud)

我找不到任何文件,这些文件之间的分离和何时使用哪个.任何人都可以详细说明吗?

bazel

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