我们有一个C++ Builder XE项目(VCL Forms Application),里面有几十个表单和单元.每当添加,删除或重命名属于项目的文件时,IDE都应该做两件事:
但是,IDE不是仅进行必要的更改,而是对现有的USEFORM和CppCompile记录进行洗牌,即使它们不受更改的影响.如果我添加一个单元(cpp和头文件),即使不需要对项目源进行任何更改,也只需要对cbproj文件进行任何更改,USEFORM都会被洗牌.
我没有看到新订单如何形成的具体模式.如果我编辑或重命名一个单元,大约一半的USEFORMs似乎改变了位置,只改变了一对或没有CppCompile记录.如果在两台不同的机器上对项目副本进行了更改,则大多数更改似乎都相似,但并非全部.这表明重新排序不是随机的.
使用Subversion合并更改时,该行为会导致问题,因为它会强制手动解决更改顺序造成的冲突.
所以问题是:什么可能导致上述行为以及如何摆脱它?
我正在迁移旧C++代码的一些部分,最初使用CodeGear C++Builder®2009版本12.0.3170.16989编译
以下代码 - 更大版本的最小版本 - -34使用任何现代编译器输出.虽然,在原始平台中输出84:
char Key[4];
Key[0] = 0x1F;
Key[1] = 0x01;
Key[2] = 0x8B;
Key[3] = 0x55;
for(int i = 0; i < 2; i++) {
Key[i] = Key[2*i] ^ Key[2*i + 1];
}
std::cout << (int) Key[1] << std::endl;
Run Code Online (Sandbox Code Playgroud)
for(int i = 0; i < 2; i++) {
char a = Key[2*i];
char b = Key[2*i + 1];
char c = a ^ b;
Key[i] = c;
}
Run Code Online (Sandbox Code Playgroud)
此外,手动展开循环似乎适用于两个编译器: …
关键字__super是Microsoft特有的.它用于访问父类的虚方法.您是否知道borland c ++/delphi编译器的替代关键词?
class MyBaseClass
{
virtual void DoSomething();
};
class MyDerivedClass : public MyBaseClass
{
virtual void DoSomething();
};
void MyBaseClass::DoSomething()
{
// some code
}
void MyDerivedClass::DoSomething()
{
__super::DoSomething(); // calls implementation of base class - no need to know name of base class
// implementation specific to derived class adding new functionality
}
Run Code Online (Sandbox Code Playgroud) TVirtualStringTree行为默认情况下,如果它的重点是 - 它会在鼠标滚轮滚动即使鼠标不在控制(除非它是对另一TVirtualStringTree).
是否有一种快速而优雅的方法来禁用此行为?
我已经这样做与OnMouseWheel事件,并检查PtInRect是否Mouse.CursorPos如果是在控制,但我有一种感觉,有一种更好的方式做同样的,因为这样,我不得不定义每个树视图我想补充,也是一个新的事件处理何时聚焦/取消聚焦控件,所以我希望必须有更好的方法来禁用它.
所以要清楚,我希望鼠标滚轮功能像往常一样工作,但只有当鼠标在VirtualTreeView上时.
delphi c++builder virtualtreeview delphi-2010 c++builder-2010
我正在尝试将GLScene安装到RAD Studio 2010中,目的是从大多数C++项目中使用它.我下载了最新的快照(5991,2011年11月)并且一直在尝试编译和安装两个主要的软件包: GLScene_DesignTime和GLScene_RunTime.我甚至没有尝试过其他一些库(CUDA等),我只想让基本软件包运行.
我遇到了一些问题,其中一个是我无法解决的问题,而且我正在寻求那些已成功安装GLScene的人的帮助,或者可能知道如何解决这些Delphi编译器错误.
编译时,许多文件都出现以下错误:
[DCC Warning] GLSelection.pas(297): W1025 Unsupported language feature: 'abstract class method'
Run Code Online (Sandbox Code Playgroud)
这是由方法声明引起的:
TGLBaseSelectTechnique = class
public
class function IsSupported: Boolean; virtual; abstract;
Run Code Online (Sandbox Code Playgroud)
似乎Delphi 2010中不支持虚拟抽象类方法,我通过删除' abstract'并提供虚拟实现来解决它,例如只返回false.
我现在遇到两个更严重的错误.编译时,编译器失败如下:
[DCC Fatal Error] Exception EAccessViolation: Access violation at address 05AE8ED9 in module 'dcc140.dll'. Read of address 00000003
[DCC Error] Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Run Code Online (Sandbox Code Playgroud)
它没有说明是什么文件引起了这个,但我认为它是由它造成的Spline.pas.偶尔也不经常,我得到这个:
[DCC …Run Code Online (Sandbox Code Playgroud) 我想在这里证实,如果我理解正确的是如何TCriticalSection和Synchronize操作.
据我所知,现在Synchronize使用SendMessage(更新:或者至少在下面几条评论中提到的较旧的VCL版本中使用它),它暂停当前正在执行的线程(以及任何其他线程),不像那样PostMessage,然后执行所需功能(来自主线程).在SendMessage执行时"停止"多线程.
但我不确定TCriticalSection.比方说我创建这样的东西:
// Global variables somewhere in my code any thread can access
boost::scoped_ptr<TCriticalSection> ProtectMyVarAndCallFnction(new TCriticalSection);
int MyVariable1;
void CallMyFunctionThatAlsoModifiesMoreStuff() { /* do even more here */ };
// Thread code within one of the threads
try {
ProtectMyVarAndCallFnction->Acquire();
MyVariable1++;
CallMyFunctionThatAlsoModifiesMoreStuff();
}
__finally {
ProtectMyVarAndCallFnction->Release();
}
Run Code Online (Sandbox Code Playgroud)
现在,我的问题是 - 关键部分如何"知道"我在这种情况下保护MyVariable1以及被调用的函数可以修改什么?
如果我理解正确 - 它没有 - 并且我有责任在任何线程中正确调用Acquire()想要更改MyVariable1或调用此函数(或执行任何两个).换句话说,我认为TCriticalSection是用户定义的块,它定义了我分配给它的逻辑.它可以是一组变量或任何特定函数,只要我在可能写入此块或使用此函数的所有线程中调用Acquire().例如,"DiskOp"可能是我TCriticalSection在磁盘上写入的名称,"Internet"可能是TCriticalSection调用从Internet检索某些数据的函数的名称.我弄错了吗?
此外,在这种情况下,TCriticalSection是否总是需要成为一种全局变量?
delphi multithreading c++builder critical-section synchronize
我是新手程序员.我需要in在C++ Builder XE中使用Delphi的运算符,如下所示:
if (dgColLines in DBGrid->Options)
// include vertical lines in total (one per column)
TotalColumnWidth = TotalColumnWidth + ColumnCount;
Run Code Online (Sandbox Code Playgroud)
if (dgColLines **in** DBGrid->Options)
Run Code Online (Sandbox Code Playgroud)
如何在C++ Builder中做到这一点?
提前致谢.
我创建了一个继承自TCustomControl并发布其属性Align的自定义控件TControl.但是,当我在C++ Builder项目中使用此自定义控件时,它引发了异常
Project Launcher.exe raised exception class EReadError with message 'Property Align does not exist'.
这是自定义控件的代码.
unit GameListCtrl;
interface
uses
SysUtils, Classes, Controls;
type
TGameList = class(TCustomControl)
private
protected
procedure Paint; override;
public
{ Public declarations }
published
property Align default alLeft;
end;
implementation
{ TGameList }
procedure TGameList.Paint;
begin
inherited;
end;
end.
Run Code Online (Sandbox Code Playgroud) 在将Embarcadero C++ Builder更新到新版本后,我们的项目突然无法构建.这只发生在我们的一个项目中.对于大多数团队成员而言,相同的代码构建没有错误.在我的计算机上,每次都会失败.
在构建选项卡中:
[ilink32] Fatal: Out of memory
Run Code Online (Sandbox Code Playgroud)
在输出选项卡中:
Build FAILED.
c:\program files (x86)\embarcadero\studio\18.0\Bin\CodeGear.Cpp.Targets(3517,5): error : Fatal: Out of memory
Run Code Online (Sandbox Code Playgroud)
没有更多信息.
如果我启用动态RTL链接,项目链接没有错误.例如,如果我们的Debug目标启用了该设置,则项目将在Debug中链接,但不在Release中.
我该如何解决这个问题?如何为链接器提供更多内存?
(下面的实际问题)
我经常将API头转换为Delphi.有时结构对齐有问题,或者我想念包装选项#pragma pack(push, 1).要检查我是否具有正确的对齐和大小,我使用扩展的RTTI通过这个简单的函数在我的翻译记录中显示偏移量:
procedure WriteOffsets(Info: Pointer);
var
LContext: TRttiContext;
LType: TRttiType;
LField: TRttiField;
begin
LType := LContext.GetType(Info);
if Assigned(LType) then
if LType.TypeKind = tkRecord then
begin
Writeln((' ' + LType.QualifiedName + ' = record ').PadRight(48),
' // size ', LType.TypeSize);
for LField in LType.GetFields do
Writeln((' ' + LField.Name + ': ' + LField.FieldType.Name + ';').PadRight(48),
' // offset ', LField.Offset);
Writeln(' end;');
Writeln;
end
else
begin
Writeln(LType.QualifiedName, ' is not a record'); …Run Code Online (Sandbox Code Playgroud) c++builder ×10
delphi ×7
c++ ×3
delphi-2009 ×1
delphi-2010 ×1
glscene ×1
ide ×1
set ×1
synchronize ×1