小编hyp*_*rum的帖子

C++重复符号

(苹果电脑)

我尝试了名称空间,包括警卫,编译指示一次等.

基本上,这是结构:

的CMakeLists.txt

add_executable(Game Game/main.cpp Game/rtexture.cpp)
Run Code Online (Sandbox Code Playgroud)

游戏/ main.cpp中

#include "cleanup.h"

//...
cleanup(foobar);
Run Code Online (Sandbox Code Playgroud)

游戏/ rtexture.cpp

#include "cleanup.h"

//...
cleanup(foobar);
Run Code Online (Sandbox Code Playgroud)

cleanup.h

//various includes

template<typename T, typename... Args>
void cleanup(T *t, Args&&... args){
    //Cleanup the first item in the list
    cleanup(t);
    //Recurse to clean up the remaining arguments
    cleanup(std::forward<Args>(args)...);
}
/*
 * These specializations serve to free the passed argument and also provide the
 * base cases for the recursive call above, eg. when args is only a single item
 * one …
Run Code Online (Sandbox Code Playgroud)

c++ macos cmake duplicates

7
推荐指数
2
解决办法
1717
查看次数

由于分段错误,OpenFL和Lime无法运行

最近,我发现(在Mac OS X Mavericks上)由于"分段错误",OpenFL和LIME(使用命令行工具)无法正常工作.

在我进入细节之前,这里有一些背景知识.

  • 我最初从OpenFL网站提供的安装程序中获得了Haxe + Neko.
  • 我从那里的说明安装了OpenFL.
  • 后来,当使用标准的Haxe编码时,我需要Neko,但它显然没有安装.
  • 我从Neko的网站安装了Neko.

而现在,我打字的时候得到这个错误limeopenfl或使用他们的任何功能(例如建筑):

Called from lime/utils/ByteArray.hx line 109
Called from lime/system/System.hx line 286
Called from lime/system/System.hx line 405
Uncaught exception - Segmentation fault
Run Code Online (Sandbox Code Playgroud)

无论如何,我不知道背景是否与它有任何关系.我查看了Ubuntu论坛,但没有任何对我有用的东西.任何帮助,将不胜感激; 我在"类似问题"或其他任何地方都找不到太多相关内容.

Haxe编译器3.1.3 + OpenFL 3.0.0 beta.(根据haxelib upgrade描述.)

haxe neko segmentation-fault openfl haxelib

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

可变参数模板的单独定义

(最后的问题)

最近,我问了一个关于如何修复链接器错误的问题(关于模板void的多个定义的重复符号).

因为我在多个源文件中使用函数,所以我建议使用关键字inline来允许标头中的声明或将声明放在已编译的源文件中.

在我意识到inline有一些不好的反响后,我把我的声明放在一个源文件中.

现在这没关系,除了可变参数模板:

template<typename T, typename... Args>
void cleanup(T *t, Args&&... args);
Run Code Online (Sandbox Code Playgroud)

我找到了一些明显的解决方案 - 但不是变量模板 - 使用.tpp文件(但它开始再次声明重复的符号)或保留源文件并添加显式实例化.

但是void cleanup有可能使用数百种参数组合,所以我不想明确地实例化所有内容.

问题: 那么,我将如何进行

  1. 将可变参数模板定义保留在源文件中,或
  2. 将定义放在.tpp文件中而不会得到重复的符号,并最终避免使用inline

.tpp声明的重复/未定义符号错误示例,并将上述模板定义分别放在源文件中.

duplicate symbol __Z7cleanupI10SDL_WindowJEEvPT_DpOT0_ in:
    CMakeFiles/Game.dir/Game/main.cc.o
    CMakeFiles/Game.dir/Game/RichTools/rtexture.cc.o
Run Code Online (Sandbox Code Playgroud)

_

Undefined symbols for architecture x86_64:
  "void cleanup<SDL_Renderer, SDL_Window*&>(SDL_Renderer*, SDL_Window*&&&)", 
referenced from:
cleanQuit() in main.cpp.o
ld: symbol(s) not found for architecture x86_64
Run Code Online (Sandbox Code Playgroud)

c++ templates undefined-symbol variadic-templates

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

如何避免不支持的帧速率错误?

我在Macbook上,我正在尝试使用ffmpeg库从相机中读取视频.相机是一个10米的USB水下相机.我通过名为ffmpeg-d的D绑定使用C API.但是,在尝试打开输入时,我得到了:

[avfoundation @ 0x7fe0d2800000] Selected framerate (29.970030) is not supported by the device
[avfoundation @ 0x7fe0d2800000] Supported modes:
[avfoundation @ 0x7fe0d2800000]   160x120@[30.000030 30.000030]fps
[avfoundation @ 0x7fe0d2800000]   176x144@[30.000030 30.000030]fps
[avfoundation @ 0x7fe0d2800000]   320x240@[30.000030 30.000030]fps
[avfoundation @ 0x7fe0d2800000]   352x288@[30.000030 30.000030]fps
[avfoundation @ 0x7fe0d2800000]   640x480@[30.000030 30.000030]fps
Run Code Online (Sandbox Code Playgroud)

那我怎么能避免这个问题呢?手动设置帧率是答案吗?如果是这样,我怎么能这样做?

这是一个非常简短的程序来复制我的问题.

import std.stdio;

import ffmpeg.libavdevice.avdevice;
import ffmpeg.libavcodec.avcodec;
import ffmpeg.libavformat.avformat;
import ffmpeg.libavfilter.avfilter;
import ffmpeg.libavutil.avutil;
import ffmpeg.libavutil.mem;
import ffmpeg.libavutil.pixfmt;
import ffmpeg.libswscale.swscale;

import std.string;

void main()
{
    av_register_all();
    avdevice_register_all();

    string           cameraSource        = "USB";

    AVCodecContext*  cameraCodecContext  = null;
    AVFormatContext* …
Run Code Online (Sandbox Code Playgroud)

c camera ffmpeg d frame-rate

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