标签: libc++

Osx Lion:Xcode 4.1如何设置c ++ 0x项目

我知道还有其他类似的问题,但是(我可以将C++ 11与Xcode一起使用吗?)但主要与旧版本的Osx或xcode相关,所以它们似乎并不是正确的解决方案来继续使用Osx Lion和xcode 4.1.osx Lion对c ++ 0x功能有什么要求?我想我必须使用新的libc ++作为标准库,将LLVM 3.0设置为编译器.是否有一种默认方式让LLVM 3.0在Lion上运行?

编辑:好吧,看起来它只是时间问题,直到LLVM 3.0将成为xcode 4的一部分:http: //oleb.net/blog/2011/07/whats-new-for-developers-in-lion-part-1 /

macos xcode osx-lion c++11 libc++

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

具有不完整值类型的地图

我收到以下错误:

class Test
{
    std::map<std::string,Test> test;
};
Run Code Online (Sandbox Code Playgroud)

错误是"字段具有不完整类型'测试'".我读了一些线程,建议这可能是随xcode附带的libcxx版本中的一个错误,但如果我只需将其更改为:它就不会让我感到惊讶:

class Test
{
    std::map<std::string,std::shared_ptr<Test>> test;
};
Run Code Online (Sandbox Code Playgroud)

我只想仔细检查这肯定是一个正确的错误,而不是一个错误.

干杯!

c++ std map c++11 libc++

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

libc ++ std :: istringstream不会抛出异常.错误?

配置了一个std::istringstreamfailbit设置时抛出异常的时候我没有用libc ++发生异常(这是在linux下使用libc ++编译并在libcxxrt的支持下编译).我想这是libc ++或libcxxrt中的一个错误:

#include <iostream>
#include <sstream>

template<typename T> std::istream &getvalue(std::istream &is, T &value, const T &default_value = T())
{
    std::stringstream ss;
    std::string s;
    std::getline(is, s, ',');
    ss << s;
    if((ss >> value).fail())
        value = default_value;
    return is;
}

int main()
{
    std::string s = "123,456,789";
    std::istringstream is(s);
    unsigned n;

    try
    {
        is.exceptions(std::ios::failbit | std::ios::eofbit);

        getvalue(is, n);
        std::cout << n << std::endl;

        getvalue(is, n);
        std::cout << n << std::endl;

        // Disable EOF exception on last …
Run Code Online (Sandbox Code Playgroud)

c++ language-lawyer libc++

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

使用lambda构造std :: function时libstdc ++和libc ++之间的不同行为

这个问题来自这个问题.

使用clang 3.4和libstdc ++ 编译以下代码:

#include <functional>

int main() {
    std::function<void()> f = []() {};
}
Run Code Online (Sandbox Code Playgroud)

但是使用clang 3.4和libc ++ 失败了:

In file included from main.cpp:1:
In file included from /usr/include/c++/v1/functional:465:
In file included from /usr/include/c++/v1/memory:599:
/usr/include/c++/v1/tuple:320:11: error: rvalue reference to type '<lambda at main.cpp:4:31>' cannot bind to lvalue of type '<lambda at main.cpp:4:31>'
        : value(__t.get())
          ^     ~~~~~~~~~
/usr/include/c++/v1/tuple:444:8: note: in instantiation of member function 'std::__1::__tuple_leaf<0, <lambda at main.cpp:4:31> &&, false>::__tuple_leaf' requested here
struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
       ^ …
Run Code Online (Sandbox Code Playgroud)

c++ lambda c++11 libc++ c++14

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

在Linux上使用`libc ++`进行编译时,对__cxa_thread_atexit @@ CXXABI`的未定义引用

我正在尝试使用libc ++,libc ++ abiclang ++ 3.6.0Arch Linux x64上编译我的项目.

项目编译正确,但无法链接以下错误:

错误:CMakeFiles/main.cpp.o:对符号'__cxa_thread_atexit @@ CXXABI_1.3.7'的未定义引用

/usr/lib/libstdc++.so.6: - 1:错误:添加符号时出错:命令行中缺少DSO

我正在使用-stdlib=libc++ -lc++abi标志进行编译和链接.

我应该链接哪些额外的库?我错过了一面旗帜吗?

c++ linux linker clang libc++

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

省略一些C++子系统

我注意到,使用emscripten,即使是相对较小的C++文件也可以很快变成相当庞大的JavaScript文件.例:

#include <memory>
int main(int argc, char** argv) {
  std::shared_ptr<int> sp(new int);
}
Run Code Online (Sandbox Code Playgroud)

使用像这样的命令用最近的emsdk编译它

em++ -std=c++11 -s DISABLE_EXCEPTION_CATCHING=1 -s NO_FILESYSTEM=1 \
     -s NO_BROWSER=1 -s NO_EXIT_RUNTIME=1 -O3 -o foo.js foo.cc
Run Code Online (Sandbox Code Playgroud)

生成的文件超过400k.随着-g抛出我可以做

grep -n '^function _' foo.js | c++filt -_
Run Code Online (Sandbox Code Playgroud)

看看我们在那里有什么样的功能.这里有些例子:

std::__1::moneypunct<char, false>::do_thousands_sep() const
std::__1::locale::~locale()
std::__1::basic_string<wchar_t, …>::~basic_string()
std::__1::time_get<…>::__get_day(…) const
std::__1::codecvt<wchar_t, char, __mbstate_t>::codecvt(unsigned int)
std::__1::locale::__imp::install(std::__1::locale::facet*, long)
_printf_core
Run Code Online (Sandbox Code Playgroud)

我自己并没有打电话给任何人,但是所有的功能都包括在内.可能其中许多都包含在一些虚拟功能表中.其他可能是由于一些静态初始化器.

如果这是正常的代码链接到我的硬盘驱动器上的某个共享库; 我不反对.但只需要一个共享指针,就可以传输半兆字节的JavaScript代码?必须有办法避免这种情况.

javascript c++ libc++ emscripten

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

排序算法是否应该在比较函数中传递相同的元素

std :: sort的libcxx(llvm版本的c ++标准库)使用相同的元素调用比较谓词,即比较函子的两个参数都指向要排序的序列中的相同位置.一个简化的例子来说明这一点.

$ cat a.cc
#include <algorithm>
#include <vector>
#include <cassert>

int main(int argc, char** argv) {
  int size = 100;
  std::vector<int> v(size);

  // Elements in v are unique.
  for (int i = 0; i < size; ++i)
    v[i] = i;

  std::sort(v.begin(), v.end(),
            [&](int x, int y) { assert(x != y); return x < y; });

  return 0;
}

$ clang++ -std=c++11 -stdlib=libc++ a.cc -o a.out
$ ./a.out
a.out: a.cc:14: auto main(int, char **)::(anonymous class)::operator()(int, int) const: Assertion …
Run Code Online (Sandbox Code Playgroud)

c++ sorting algorithm libstdc++ libc++

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

cvxpy stlibc ++ MacOS Mojave上的安装错误

尝试在Mac上使用pip install安装cvxpy软件包时,收到以下错误消息:

warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from cvxpy/cvxcore/src/cvxcore.cpp:15:
cvxpy/cvxcore/src/cvxcore.hpp:18:10: fatal error: 'vector' file not found
#include <vector>
^~~~~~~~
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

Mac正在运行OS Mojave.

python python-3.x libc++ cvxpy

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

Clang无法在macOS中编译基本头文件(例如&lt;iostream&gt;)

我的macOS版本是 10.14

Xcode版本是 10.2

为clang编写插件。我只是使用以下命令从Github安装llvm和clang。

git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" ../llvm
Run Code Online (Sandbox Code Playgroud)

然后使用clang --version,它显示:

clang version 10.0.0 (https://github.com/llvm/llvm-project.git 73f702ff192475b27039325a7428ce037771a5de)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Users/kim/GitHub/llvm-project/build/bin
Run Code Online (Sandbox Code Playgroud)

现在,我只是尝试编译非常简单的Hello World程序:

git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" ../llvm
Run Code Online (Sandbox Code Playgroud)

用命令 clang++ test.cpp -o test

但不幸的是,它无法编译错误:

In file included from test.cpp:1:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/iostream:37:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/ios:214:
In file included from …
Run Code Online (Sandbox Code Playgroud)

c++ macos header-files llvm-clang libc++

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

libc ++对std :: map / set :: equal_range的实现产生了意外的结果

我注意到在clang的libc ++中std::set::equal_range(与相同std::map)给出的结果与libstdc ++不同。我一直认为equal_range应该返回std::make_pair(set.lower_bound(key), set.upper_bound(key))cppreference和libstdc ++所做的等效。但是在libc ++中,我有一个给出不同结果的代码。

#include <set>
#include <iostream>
#include <iterator>

struct comparator {
    using range_t = std::pair<int, int>;
    using is_transparent = std::true_type;
    bool operator()(int lhs, int rhs) const
    {
        return lhs < rhs;
    }
    bool operator()(int lhs, range_t rhs) const
    {
        return lhs < rhs.first;
    }
    bool operator()(range_t lhs, int rhs) const
    {
        return lhs.second < rhs;
    }
};

using range_set = std::set<int, comparator>;

int main()
{
    range_set set = …
Run Code Online (Sandbox Code Playgroud)

c++ libc++

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