www.digitalmars.com         C & C++   DMDScript  

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
Jul 23 2007