www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics



c++ - How to memory read with memory padding??

Hi guys, this is my first time posting, and i've already looked around and
found a few useful post regarding the memory padding stuff... but none of them
shows how to read the memory directly with the padding.

I am working on a program, it has about 150 "signals" each signal is just a
struct... so i have 150 different structs...

I am making something to dynamically parse the signal. So i have a file
defined the structure of the signal, then when i pass the signal to my
function i just do myFunction( signal, my_signal_structure );

my_signal_structure is basically just an int array, say, 1 = int8, 2 = int16,
3 = int32, 4 = MY_STRUCT1, 5 = MY_STRUCT2 etc.. (i used enum)

When i read it, i use a for loop and a switch statement to go through the
signal. i just do signal[memory_position], and read directly from the memory.
And i know my_signal_structure[i] will give me what i am reading...

say signal[14], and my_signal_structure[4] is an int32, then i know that is an
int32, and i need to increment my memory_position by 4 after that.

It works fine when i test it with simple stuff, but when i put in more complex
struct, then the memory padding kicks in...

is there a simple way to read the memory and at the same time dealing with the
padding?
Jul 23 2007