digitalmars.D - Some Problems!!
- "aelmetwaly" <aelmetwaly gawab.com> Oct 01 2004
- kinghajj <kinghajj_member pathlink.com> Oct 01 2004
- Ben Hinkle <bhinkle4 juno.com> Oct 01 2004
// Questions
Hi there,
Please I need advice on the following subjects:
1- Some macro #defines are deficult to implement in D. eg.:
#define rvaDLLName szName
Is there any other way than doing global search and replace?
2- How I can implement template functions in D. eg.:
in C++:
template <class T> void DumpOptionalHeader(T* pImageOptionalHeader);
I converted it to:
template DumpOptionalHeader(T = IMAGE_OPTIONAL_HEADER32) {
void DumpOptionalHeader(T* pImageOptionalHeader) // 'T' is
IMAGE_OPTIONAL_HEADER32/64
{ ... } }
Is this right? or is there any beter way?
3- The following code compile in C++ but not in D and compiler give outside
array bounds error. why?
in C++:
typedef struct DATASYM32 {
unsigned short reclen; // Record length
unsigned short rectyp; // S_LDATA32, S_GDATA32 or S_PUB32
CV_uoff32_t off;
unsigned short seg;
CV_typ_t typind; // Type index
unsigned char name[1]; // Length-prefixed name
} DATASYM32;
typedef DATASYM32 PUBSYM32;
PCSTR pszUndecoratedName = (PCSTR)&pDataSym32->name[1]; // < == NOTE this
I converted it to but the markered array line give outside array bounds
error [0..1]
struct DATASYM32 {
ushort reclen; // Record length
ushort rectyp; // S_LDATA32, S_GDATA32 or S_PUB32
CV_uoff32_t off;
ushort seg;
CV_typ_t typind; // Type index
ubyte name[2]; // Length-prefixed name // originally, it was
name[1] but the code below
// gives outside of array bounds error although it compiles wright
in C++. ??!!!
} ;
alias DATASYM32 PUBSYM32;
PCSTR pszUndecoratedName = cast(PCSTR)&pDataSym32.name[1];
4- about primitive types in C++ is:
unsigned long => ulong or uint ?
and other types, and it's equivelent in d ?
5- Is there any documentation or references about OMF lib format on the
internet. maybe I can relate the data
structures with the new Microsoft COFF archive format!
Oct 01 2004
In article <cjknl2$19d5$1 digitaldaemon.com>, aelmetwaly says...// Questions Hi there, Please I need advice on the following subjects: 1- Some macro #defines are deficult to implement in D. eg.: #define rvaDLLName szName Is there any other way than doing global search and replace?
typedef szName rvaDDLName;
Oct 01 2004
aelmetwaly wrote:// Questions Hi there, Please I need advice on the following subjects:
in general see http://www.digitalmars.com/d/cpptod.html or ctod.html or pretod.html1- Some macro #defines are deficult to implement in D. eg.: #define rvaDLLName szName Is there any other way than doing global search and replace?
alias szName rvaDLLName2- How I can implement template functions in D. eg.: in C++: template <class T> void DumpOptionalHeader(T* pImageOptionalHeader); I converted it to: template DumpOptionalHeader(T = IMAGE_OPTIONAL_HEADER32) { void DumpOptionalHeader(T* pImageOptionalHeader) // 'T' is IMAGE_OPTIONAL_HEADER32/64 { ... } } Is this right? or is there any beter way?
looks ok to me3- The following code compile in C++ but not in D and compiler give outside array bounds error. why? in C++: typedef struct DATASYM32 { unsigned short reclen; // Record length unsigned short rectyp; // S_LDATA32, S_GDATA32 or S_PUB32 CV_uoff32_t off; unsigned short seg; CV_typ_t typind; // Type index unsigned char name[1]; // Length-prefixed name } DATASYM32; typedef DATASYM32 PUBSYM32; PCSTR pszUndecoratedName = (PCSTR)&pDataSym32->name[1]; // < == NOTE this I converted it to but the markered array line give outside array bounds error [0..1] struct DATASYM32 { ushort reclen; // Record length ushort rectyp; // S_LDATA32, S_GDATA32 or S_PUB32 CV_uoff32_t off; ushort seg; CV_typ_t typind; // Type index ubyte name[2]; // Length-prefixed name // originally, it was name[1] but the code below // gives outside of array bounds error although it compiles wright in C++. ??!!! } ; alias DATASYM32 PUBSYM32; PCSTR pszUndecoratedName = cast(PCSTR)&pDataSym32.name[1];
I don't know why it failed - one would think declaring name[2] would allow name[1] to be dereferenced.4- about primitive types in C++ is: unsigned long => ulong or uint ? and other types, and it's equivelent in d ?
it depends. see the D doc. typically in C long is 32 bits. "long long" is 64.5- Is there any documentation or references about OMF lib format on the internet. maybe I can relate the data structures with the new Microsoft COFF archive format!
try googling. I don't have any references handy.
Oct 01 2004









kinghajj <kinghajj_member pathlink.com> 