does anybody know how treat these packed records in visual c++?
On the help file it's stated:
1 2 3 4 5 6 7 8 9 10
// Database info structure
TRTDatabaseInfo = packed record
Version : LongInt;
Size : LongInt;
ImageWidth : LongInt;
ImageHeight : LongInt;
ImageChannels : LongInt;
ActiveDetectors : LongInt;
MaxChannelCount : LongInt;
end;
And this is used in a function like this:
1 2 3 4 5 6 7 8 9
var Info : TRTDatabaseInfo;
res,i : longint;
Info.Version:=1;
Info.Size:=SizeOf(Info);
// Read database info without preview image and spectrum
ImgBufferSize:=0;
SpcBufferSize:=0;
res:=GetRoentecSpectrumDatabaseInfo(Info,nil,ImgBufferSize,nil,SpcBufferSize);
Now how would i use this Info variable in visual c++?
C++ gives no control on member alignment, as far as I know. There might be some compiler specific options though..
However, since LongInt is 4 bytes, there is no need for any padding. I think you can be sure that the order of members will be preserved, so a plain struct should be safe to use.
is not the default member alignment in visual c++ 8 bytes. In Project -> settings-> C/C++-> Code Generation
one can change this. Could there be some problems in other parts of the code if i change this to 4?
Would this do:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
typedefstruct TMyStruct{
long Version ;
long Size;
long ImageWidth;
long ImageHeight;
long ImageChannels;
long ActiveDetectors;
long MaxChannelCount;
}Arects;
float * imbuf = newfloat;
float * spcbuf = newfloat;
Arects Info1;
Info1.Version = 1; //Info.Version
Info1.Size = sizeof(Info1); //Info.Size
long res = GetRoentecSpectrumDatabaseInfo1(Info1, imbuf,0,spcbuf,0);