在Delphi XE4中编译项目后,我只需要输出可执行文件名,如MyApp32.exe和MyApp64.exe.
我在论坛中发现了一个{$ LIBSUFFIX'32'}的指令,但它似乎只适用于dll.
对可执行文件的任何建议?
谢谢.
我是一名嵌入式软件工程师,来自比特和C世界.在那个世界中,闪存中的数据由C表示为const.并且RAM中有数据.RAM昂贵且有限,而闪存便宜且足够.此外,由于碎片问题或安全规定,不允许使用new,delete,malloc等进行动态内存分配,因此首选静态设计.
我有大约2000个具有相似常量属性但行为不同的对象.所以对于他们来说,我将Shape Class定义为一个基类,它保存了我的对象的共享属性.为了表示不同的行为,Shape Class有一个名为Print()的抽象方法,它将被父母覆盖.
ShapeList是重要的部分.它是一个const数组,由"const Shapes"组成,因此它们将被链接器放入闪存部分.
以下程序产生一个输出:
I'm a Shape has 3 dots
I'm a Shape has 4 dots
I'm a Shape has 5 dots
Run Code Online (Sandbox Code Playgroud)
虽然预期产量是:
I'm a Triangle has 3 dots
I'm a Rectangle has 4 dots
I'm a Pentagon has 5 dots
Run Code Online (Sandbox Code Playgroud)
我需要多态行为.当我打印三角形时,它应该像三角形,而不是形状.我怎样才能做到这一点?
谢谢.
#include <array>
#include <cstdio>
class Shape
{
public:
const int DotCount;
Shape(const int dot): DotCount(dot) {}
virtual void Print(void) const; // this is virtual method
};
void Shape::Print(void) const
{
printf("I'm a Shape has …
Run Code Online (Sandbox Code Playgroud) 在过去的比赛中,我被要求使用0到9之间的数字生成10位数字符串.字符串中使用的任何四位子字符串都不能再次使用.
使用这些规则可以生成的最大数量的唯一字符串是多少?列出他们.
例:
如果在列表中使用字符串0243697518,则无法生成包含0243,2436,4369,3697,6975,9751和7518的字符串
为了解决这个问题,我编写了一个c ++程序,只需扫描所有的"0123456789"排列,如果之前没有使用过代码的4位子字符串,则将它们添加到解决方案列表中.但我的算法的问题是,解决方案列表的大小取决于您首先添加到列表中的起点.如果我开始从"0123456789"添加到列表中,列表最终会有504个条目,这不是最大要求.我真的很想知道如何解决这个问题,任何帮助都非常感谢.我愿意听你的数学解决方案或任何算法建议来生成所要求的列表.
#include <iostream>
#include <cstdint>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
void main(void)
{
set<string> substring_list; // holds the list of used 4 digit sub-strings
set<string> solution_list;
string code = "0123456789";
do
{
vector<string> subs;
for (int i = 0; i < 7; i++)
{
// adds all 4 digits sub-strings used in the code
subs.push_back(code.substr(i, 4));
}
if ((substring_list.find(subs[0]) == substring_list.end()) &&
(substring_list.find(subs[1]) == substring_list.end()) &&
(substring_list.find(subs[2]) == substring_list.end()) &&
(substring_list.find(subs[3]) …
Run Code Online (Sandbox Code Playgroud) 今天我尝试在XE4中编译我的XE3项目.我面临的第一个问题是使用Indy的FTCPClient.Socket.ReadBytes()方法.
在它接受TBytes类型之前,现在它坚持使用TidBytes.
定义:TIdBytes =字节数组; TBytes,我不确定我猜它是泛型类似于TArray的字节数组.
问题1:编译器为什么抱怨'[dcc32错误] HistoricalStockData.pas(298):E2033实际和正式var参数的类型必须相同'.我认为它们已经相同了.
问题2:我应该用每个新的delphi版本修改我的源代码吗?
谢谢.
我已经学会了如何使用TVirtualStringTree,我发现它非常棒.我有一个名为PackedList的自定义非可视列表,由另一个线程填充.我想实时显示TVirtualStringTree中的所有列表内容.所以我在主窗体上放了一个定时器,每500ms更新一次HexLog(即TVirtualStringTree)RootNodeCount.
我的所有数据都出现在VirtualStringTree上,我没有任何速度问题,非常好.但垂直滚动条有一个问题.当我在控件上按Ctrl + End以跳转到列表的末尾时,它会在中间某处.类似地,当我将滚动条拖动到结尾时,它不会结束.但是HexLog知道DataCount.为什么不跳到最后?如果我按几次按Ctrl + END,它会到达结尾.
在计时器例程中,我想说HexLog按代码跳转到列表的末尾.我该怎么做以及如何正确处理垂直滚动条?
procedure TMainForm.StatusUpdateTimerTimer(Sender: TObject);
begin
if (FirpList.ComOperationCount > 0) and (PacketList.Items.Count <> FirpList.ComOperationCount) then
begin
HexLog.RootNodeCount := PacketList.Items.Count;
end;
end;
procedure TMainForm.HexLogMeasureItem(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; var NodeHeight: Integer);
begin
if Sender.MultiLine[Node] then
begin
TargetCanvas.Font := Sender.Font;
NodeHeight := HexLog.ComputeNodeHeight(TargetCanvas, Node, 1, FirpList.ComOperations[Node^.Parent^.Index].DataAsHexString(FAppSettings.HexLogColumnCharWidth) + #13#10);
end;
end;
Run Code Online (Sandbox Code Playgroud)
TLama的建议回复无法正常工作,请参阅图片以获得解释:
有关详细图像说明,请参阅该链接:http://i43.tinypic.com/1445thi.png
我有一个数组保存数据将在TVirtualStringTree上表示.该阵列是线程安全且可锁定的.并由另一个线程增长.
我的问题是,当VST执行OnMeasureItem事件来测量节点的高度时,用于测量的数据可能会在使用OnGetText事件打印数据时发生变化.
我检查了事件的执行顺序,这对我的设计不利.首先它为未初始化的所有节点触发OnMeasureItem事件,然后它开始调用OnGetText事件.我的意思是,假设我们有3个节点,事件将按此顺序触发:
OnMeasureItem for node 1
OnMeasureItem for node 2
OnMeasureItem for node 3
OnGetText for node 1
OnGetText for node 2
OnGetText for node 3
Run Code Online (Sandbox Code Playgroud)
但是我需要这样的东西才能锁定:
OnMeasureItem for node 1
OnGetText for node 1
OnMeasureItem for node 2
OnGetText for node 2
OnMeasureItem for node 3
OnGetText for node 3
Run Code Online (Sandbox Code Playgroud)
保持OnMeasureItem和OnGetText事件之间获得的数据同步的最佳方法是什么?
我不想在所有OnMeasureItem()和OnGetText()事件中锁定我的数组.
谢谢.
添加onTimer:
procedure TMainForm.SyncHexLog;
begin
HexLog.BeginUpdate;
Try
if (HexLog.RootNodeCount <> FirpList.ComOperationCountLagged) then
begin
HexLog.RootNodeCount := FirpList.ComOperationCountLagged;
// measure for fast scrolling
HexLog.ReInitNode(HexLog.GetLastNoInit(), True);
if FAutoScroll then …
Run Code Online (Sandbox Code Playgroud) 今天我决定使用TParallel.For并成功用于Delphi 10.2.3
但TParallel.For有一个奇怪的定义,这种定义对我来说是新的.我也无法在Delphi文档中找到它的含义.
class function TParallel.&For(ALowInclusive, AHighInclusive: Integer; const AIteratorEvent: TProc<Integer>): TLoopResult;
Run Code Online (Sandbox Code Playgroud)
& Operator在这里是什么意思?使用TParallel.&For或TParallel.For之间有什么区别,因为两者都编译.
我编写了一个自己开发的串行端口类,为了简单起见,我使用了阻塞/同步/非重叠。我浏览了所有 MSDN 文档,这对我来说很困难。
我在从端口打开、传输或接收字节方面没有任何问题。所有操作都是同步的,并且没有线程复杂性。
function TSerialPort.Open: Boolean;
var
h: THandle;
port_timeouts: TCommTimeouts;
dcb: TDCB;
begin
Result := False;
if Assigned(FHandleStream) then
begin
// already open
Exit(True);
end;
h := CreateFile(PChar('\\?\' + FComPort),
GENERIC_WRITE or GENERIC_READ, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
// RaiseLastOSError();
if h <> INVALID_HANDLE_VALUE then
begin
{
REMARKS at https://learn.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_commtimeouts
If an application sets ReadIntervalTimeout and ReadTotalTimeoutMultiplier to MAXDWORD and
sets ReadTotalTimeoutConstant to a value greater than zero and less than MAXDWORD, one
of …
Run Code Online (Sandbox Code Playgroud) 我试着对一组字符串进行排序,好像它们是数字一样.每个字符串长度可以达到50,并且它们实际上不仅仅由数字组成.据我在论坛中理解和搜索,c ++默认按字典顺序对字符串进行排序.有没有办法更改此默认行为以符合我的需求?
我需要的是如下:
set<string> solution;
solution.insert("12X451");
solution.insert("X23454");
solution.insert("12345");
solution.insert("12315");
solution.insert("123111");
solution.insert("5231");
for (auto s : solution)
{
cout << s << endl;
}
Run Code Online (Sandbox Code Playgroud)
这打印:
123111
12315
12345
12X451
5231
X23454
Run Code Online (Sandbox Code Playgroud)
我需要的是:
5231
12315
12345
123111
12X451
X23454
Run Code Online (Sandbox Code Playgroud) 当用户按下Ctrl + End时,VirtualStringTree会垂直跳转到最后,这也很好但也是水平的.我不希望它横向走到尽头.水平滚动应该保持原样.
怎么说出来?
今天我使用AnyDAC(firedac)进行测试,以获取远程SQL Server 2012中可用的所有数据.
我从中获取数据的表有这些简单的列:
1. date - (size 3 byte)
2. time - (max 5 byte)
3. int - (4 byte)
4. bit - (1 byte)
5. int - (4 byte)
6. float - (4 byte)
7. float - (4 byte)
8. int - (4 byte)
9. int - (4 byte)
Run Code Online (Sandbox Code Playgroud)
总行大小应为最多33个字节.
好吧,在获取了我的表中可用的所有行(超过214万行)之后,我检查了FireDAC收到的tcp流量并观察到它大约是280MB,这意味着每行需要大约130字节,而我的预期值接近33字节.
我使用在服务器端定义的存储过程的另一个测量,它在上面的同一个表中有一个插入sql,我使用AnyDAC的Array DML功能调用存储过程.阵列大小为300K,我使用它增加了1880万条记录.用于它的流量实现为2.85 GB.(每行150个字节)
FireDAC或SQL Server端是否有任何配置可以减少流量?显然,这里有一些问题.有什么建议?
谢谢.
信息输出:
================================
Connection definition parameters
================================
User_Name=*****
Password=*******
SERVER=sql.***.gen
ApplicationName=Bist
Workstation=NB
DATABASE=BIST
MARS=yes
DriverID=MSSQL
================================
FireDAC info
================================
Tool = D18 …
Run Code Online (Sandbox Code Playgroud) 假设有一个有向图由以下命名的顶点组成:
"ABC", "ABD", "ACB", "ACD", "ADB", "ADC", "BAC", "BAD",
"BCA", "BCD", "BDA", "BDC", "CAB", "CAD", "CBA", "CBD",
"CDA", "CDB", "DAB", "DAC", "DBA", "DBC", "DCA", "DCB"
Run Code Online (Sandbox Code Playgroud)
这些是4个不同字母的3个字母排列.(total = 4*3*2=24
)顶点名称还描述它们之间的边.如果源的最后两个字符等于目标的前两个字符,则任何两个顶点相互连接
甲BC - > BC d
要么
D CB - > CB A.
该图与De Burjin或Kautz非常相似,但不相同.它有很强的联系,我知道它有汉密尔顿循环.
为了解决这个问题,我不是算法方面的专家,我只是通过最新的boost图库找到了hawick_unique_circuits()函数,它枚举了所有周期,这里是我的示例代码:
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/hawick_circuits.hpp>
#include "combination.hpp" // from http://howardhinnant.github.io/combinations.html
using namespace std;
using namespace boost;
typedef boost::adjacency_list<vecS, vecS, directedS, no_property, property<edge_weight_t, uint32_t> > TGraph;
TGraph m_Graph; …
Run Code Online (Sandbox Code Playgroud) delphi ×8
c++ ×3
graph-theory ×2
scroll ×2
algorithm ×1
arrays ×1
c++11 ×1
firedac ×1
indy ×1
math ×1
polymorphism ×1
serial-port ×1
sql-server ×1