(苹果电脑)
我尝试了名称空间,包括警卫,编译指示一次等.
基本上,这是结构:
的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) 最近,我发现(在Mac OS X Mavericks上)由于"分段错误",OpenFL和LIME(使用命令行工具)无法正常工作.
在我进入细节之前,这里有一些背景知识.
而现在,我打字的时候得到这个错误lime
或openfl
或使用他们的任何功能(例如建筑):
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
描述.)
(最后的问题)
最近,我问了一个关于如何修复链接器错误的问题(关于模板void的多个定义的重复符号).
因为我在多个源文件中使用函数,所以我建议使用关键字inline
来允许标头中的声明或将声明放在已编译的源文件中.
在我意识到inline
有一些不好的反响后,我把我的声明放在一个源文件中.
现在这没关系,除了可变参数模板:
template<typename T, typename... Args>
void cleanup(T *t, Args&&... args);
Run Code Online (Sandbox Code Playgroud)
我找到了一些明显的解决方案 - 但不是变量模板 - 使用.tpp文件(但它开始再次声明重复的符号)或保留源文件并添加显式实例化.
但是void cleanup
有可能使用数百种参数组合,所以我不想明确地实例化所有内容.
问题: 那么,我将如何进行
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) 我在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)