小编Mon*_*nku的帖子

如何在C++模块系统中处理模板?

我正在阅读论文A Module System for C++ 来理解C++模块,这是C++的一个提议特性.

我无法完全理解此模块架构如何导出模板.

有任何想法吗?

c++ c++20 c++-modules

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

如何在cmake中进行代码覆盖

我想在我的cmake项目中使用代码覆盖工具(lcov).我在这里阅读示例https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake 使用'add_test()'cmake函数在我的项目中添加测试.

我想创建一个名为'test_coverage'的自定义目标,在调用执行时应运行所有测试,收集其覆盖数据并在目录'code_coverage'中生成html(使用genhtml).

有没有办法可以获得我的项目中的所有测试列表及其目录路径,以便在自定义目标'test_coverage'中我可以单独执行每个测试并收集其覆盖数据?

cmake ctest

13
推荐指数
0
解决办法
9373
查看次数

什么是gcc链接器映射文件用于?

gcc/g ++链接器选项"-Map"用于生成什么".map"文件?以及如何阅读它们?

linker gcc g++ linker-flags

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

为什么要多次通过构建Linux From Scratch(LFS)?

我想了解的Linux From Scratch的概念,并想知道为什么有建筑多遍binutils,gcc等等.

为什么我们需要分别使用pass1和pass2?为什么我们不能建造工具通1,然后用它们建造gcc,glibc,libstdc++,等.

linux gcc linux-from-scratch

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

如何在C++中使用"using"关键字

我很困惑哪一个是使用usingC++关键字命名空间的更好方法.假设以下代码位于头文件中backtrace.h

#include <memory>
using my_namespace1::component1;
using my_namespace2::component2;
namespace my_application {
  namespace platform_logs {
    class backtrace_log {
          //code that creates instances of my_namespace1::component1 and my_namespace2::component2
    };
  }
}
Run Code Online (Sandbox Code Playgroud)

要么

#include <memory>    
namespace my_application {
  namespace platform_logs {
    using my_namespace1::component1;
    using my_namespace2::component2;

    class backtrace_log {
          //code that creates instances of my_namespace1::component1 and my_namespace2::component2
    };
  }
}
Run Code Online (Sandbox Code Playgroud)

哪个更好,为什么?

c++

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

构建共享库时出现未定义的隐藏符号“__dso_handle”错误

我正在尝试构建我的应用程序组件之一的共享库(在 linux 上)。

我正在使用以下命令来创建它:

g++ -g -shared -Wl,--cref,-Map,ComponentA.map -o ComponentA.so \
 ../../components/componentA_all.o -nostdlib -lgcc
Run Code Online (Sandbox Code Playgroud)

在链接阶段,我收到以下错误:

/home/manik/components/componentA.cpp:218: undefined reference to `__dso_handle'
/usr/bin/ld: ../../components/componentA_all.o: relocation R_386_GOTOFF against undefined hidden symbol `__dso_handle' can not be used when making a shared object
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
makefile:188: recipe for target 'ComponentA.so' failed
Run Code Online (Sandbox Code Playgroud)

如果我在“componentA.cpp”中有静态类数组,例如:

static component_info_a cx_objs[10];
Run Code Online (Sandbox Code Playgroud)

错误源的行号位于此位置。我不明白错误的原因是什么。struct component_info_a 的声明写在同一个 componentA.cpp 文件中。

此源文件的链接阶段之前的编译命令是:

g++ -Wp,-MMD,componentA.d -pthread -pipe -c -Woverloaded-virtual  -DUSING_X11 -g -D_REENTRANT -pthread -fpic  -I../.. -I/usr/share …
Run Code Online (Sandbox Code Playgroud)

c++ ld

5
推荐指数
0
解决办法
5781
查看次数

OpenVR、SteamVR 和 Unity3D 如何协同工作?

我试图了解 Vive 的 VR 平台堆栈,以及它的游戏是如何开发的。我正在努力理解 openVR、steamVR 和 Unity 到底在什么地方适合图片。

到目前为止,我的理解是:

openVR - Hardware independent layer providing APIs for peripheral access. 
         That is it can provide access to either Oculus or Vive hardware via 
         a defined interface.

SteamVR - Provides access to hardware to games developed either in unity or
          unreal.
Unity3D - A game engine to develop games.
Run Code Online (Sandbox Code Playgroud)

如果有人可以纠正我,我将不胜感激。或者如果我的理解是正确的,那么为什么不能unity 3D直接通过openVR.

unity-game-engine steam openvr

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

xsd.exe 不会为 xs:list 标记创建集合(数组或列表)

我有以下 xsd 标签,我希望在反序列化时创建一个集合,但它没有。

<Metrics>
....
....
<xs:simpleType name="idType">
    <xs:restriction base="xs:int">
        <xs:minInclusive value="0"/>
        <xs:maxInclusive value="99"/>
    </xs:restriction>
</xs:simpleType>
...
...
<xs:element name="RPT">
    <xs:simpleType>
        <xs:list itemType="idType"/>
    </xs:simpleType>
</xs:element>
...
...
</Metrics>
Run Code Online (Sandbox Code Playgroud)

当我使用 command 创建类时xsd /c <xsd-filename>.xsd,创建的 RPT 是:

public partial class Metrics 
{
   ...
   ...
   private string rPTField;
   ...
   ...
}
Run Code Online (Sandbox Code Playgroud)

我想RPT成为一个返回列表元素的集合类型。我怎样才能做到这一点 ?

xml xsd xsd.exe

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

如何从泛型函数中检索值类型值?

我有一个泛型函数,我用来从sqlite数据库中检索键值对值.

功能签名是:

T Retrieve<T>(string key);
Run Code Online (Sandbox Code Playgroud)

我想null在数据库中不存在密钥时返回.我可以reference types用这个签名来做这件事但不能用value types

我可以将签名更改为object Retrieve(string key);然后将其转换为类型,T但我想知道是否还有其他更好的方法来实现此目的.

c#

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

"-Bdynamic"编译标志有什么作用?

我正在阅读英特尔Inspector XE 2013文档,他们提到了标志"-Bdynamic"的设置.谁能告诉我这面旗子有什么作用?我已经搜索了gnu编译选项,但还没有看到这个.

谢谢,Sheeri

c c++ dynamic-compilation

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