Click here to Skip to main content
15,918,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Making objects talk with each other? Pin
Maximilien15-Jul-04 4:43
Maximilien15-Jul-04 4:43 
GeneralRe: Making objects talk with each other? Pin
0v3rloader15-Jul-04 4:59
0v3rloader15-Jul-04 4:59 
AnswerRe: Making objects talk with each other? Pin
Antti Keskinen15-Jul-04 9:18
Antti Keskinen15-Jul-04 9:18 
GeneralRe: Making objects talk with each other? Pin
0v3rloader15-Jul-04 10:02
0v3rloader15-Jul-04 10:02 
GeneralRe: Making objects talk with each other? Pin
0v3rloader15-Jul-04 10:12
0v3rloader15-Jul-04 10:12 
GeneralRe: Making objects talk with each other? Pin
Antti Keskinen15-Jul-04 11:36
Antti Keskinen15-Jul-04 11:36 
GeneralRe: Making objects talk with each other? Pin
0v3rloader15-Jul-04 11:46
0v3rloader15-Jul-04 11:46 
Generalpacked data strcutures Pin
Henry miller15-Jul-04 3:51
Henry miller15-Jul-04 3:51 
I'm looking for the best C++ solution to this data situation. I need something as generic C++ as I can get because we may switch compilers sometime in the near future.

I'm implimenting an ISO9660 filesystem, which stores on disk structures that look something like this in C

#pragma pack(1)
struct filename {
BYTE version;
ULONG bigendianBlockAddress;
ULONG littleendianBlockAddress;
BYTE filenameLenght;
BYTE filename[30]; // not C style string
#pragma pack()

That is block address that are both little endian and big endian, but otherwise exactly the same value. The perfect situation for a class. something like:

#pragma pack(1)
class bothorder {
ULONG big;
ULONG little;
public:
ULONG operator=(...)
...
};

This structur occures all over, and manipulating it will be a large part of the rest of my code.

Now I get (through an interface that I cannot change) a pointer memory space with the first structure. Is it safe to use assignment new or some cast to place the class exactly there, or should I expect compilers to use more than the 8 bytes the ULONG takes for some internal use? (such as a this pointer?)

Is there a better way to solve this problem? I'd like to make the code as readable as I can.

I know pragma pack isn't in standard C++, but it appears all compilers support it.

Those who know ISO9660 will note a big advantage for classes: I intentionally introduced a bug, the little endian number should have been before the big endian number!
GeneralRe: packed data strcutures Pin
vmaltsev15-Jul-04 11:52
vmaltsev15-Jul-04 11:52 
GeneralRe: packed data strcutures Pin
Henry miller15-Jul-04 12:04
Henry miller15-Jul-04 12:04 
GeneralCInternetSession timeout Pin
fredvinzenz15-Jul-04 3:46
fredvinzenz15-Jul-04 3:46 
Generalwsprintf Pin
vikramlinux15-Jul-04 2:37
vikramlinux15-Jul-04 2:37 
GeneralRe: wsprintf Pin
V.15-Jul-04 2:47
professionalV.15-Jul-04 2:47 
GeneralRe: wsprintf Pin
vikramlinux15-Jul-04 2:56
vikramlinux15-Jul-04 2:56 
GeneralRe: wsprintf Pin
V.15-Jul-04 3:11
professionalV.15-Jul-04 3:11 
GeneralRe: wsprintf Pin
vikramlinux15-Jul-04 3:46
vikramlinux15-Jul-04 3:46 
GeneralRe: wsprintf Pin
David Crow15-Jul-04 3:23
David Crow15-Jul-04 3:23 
Generala threading question Pin
ns15-Jul-04 2:15
ns15-Jul-04 2:15 
GeneralRe: a threading question Pin
jmkhael15-Jul-04 3:12
jmkhael15-Jul-04 3:12 
GeneralRe: a threading question Pin
David Crow15-Jul-04 3:28
David Crow15-Jul-04 3:28 
GeneralRe: a threading question Pin
ns15-Jul-04 3:59
ns15-Jul-04 3:59 
GeneralRe: a threading question Pin
V.15-Jul-04 4:13
professionalV.15-Jul-04 4:13 
GeneralRe: a threading question Pin
David Crow15-Jul-04 4:19
David Crow15-Jul-04 4:19 
GeneralRe: a threading question Pin
ns15-Jul-04 6:31
ns15-Jul-04 6:31 
GeneralCSplitterWnd inside another Pin
John Oliver15-Jul-04 1:50
John Oliver15-Jul-04 1:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.