我终于有一些时间来升级我的视频捕获类。我想比较VFW(我已经使用到现在)和DirectShow。正如预期的那样,DirectShow更快,但是当我添加信息文本时,突然AnsiString::sprint()
不再是AnsiString
的成员。包括DShow.h中断BDS2006上的VCL AnsiString :: sprintf()
经过一番斗争,我找到了一个解决方法,AnsiString::printf()
仍然有效,但我很好奇如何解决这个问题。也许一些定义从dshow.h
和dstring.h
冲突?
我砍掉所有不必要的代码来显示这个问题:
//$$---- Form CPP ----
//---------------------------------------------------------------------------
#include <vcl.h>
#include <dshow.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
static int i=0;
Caption=AnsiString().sprintf("%i",i); // this does not work
AnsiString s; s.printf("%i",i); Caption=s; // this does work
i++;
}
//---------------------------------------------------------------------------
这仅仅是一个简单的VCL窗体应用程序上有一个单一的TTimer
。 TTimer
正在递增计数器i
并将其输出到表格的Caption
中。该DirectX库甚至没有链接,只是头包括!
链接器输出误差:
[C++ Error] Unit1.cpp(20): E2316 'sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA' is not a member of 'AnsiString'
如果我交换vcl.h
和dshow.h includes, the compiler stops in
dstring.h`在这条线:
AnsiString& __cdecl sprintf(const char* format, ...); // Returns *this
利用该错误消息:
[C++ Error] dstring.h(59): E2040 Declaration terminated incorrectly
所以,显然有一些冲突(AnsiString
关键字是t他问题)。将dshow.h
置入namespace
也无济于事。
有没有人有任何线索?
Q1。如何解决这个问题?第二季度销售价格下降,第二季度销售价格下降,第三季度销售价格下降。什么/究竟在哪里造成这种情况?
,我能想到的,并且应该工作(但我想,以避免它,如果我能)唯一的解决办法,是建立与的DirectShow东西的OBJ(或DLL),和然后将其链接到一个标准的VCL项目中,其中不包括dshow.h
,当然,出口也必须没有任何有趣的东西。
在包括dshow后尝试“#undef sprintf”。h – JeffRSon
@JeffRSon是的,它的工作作出答案,所以我可以接受它是奇怪的,因为VCL包括在DShow之前......但它的工作原理 – Spektre