I figured it out. I figured if I made my structure a class, that it would fix my problem. But it didn't. This is my problem:
I have an array global variable:
Code:
BOARD_INFO* gBoardInfo;
And the definition of BOARD_INFO is:
Code:
class BOARD_INFO {
public:
char name[BUFF_LEN];
int* pChDev;
FEATURE_TABLE* pFT;
ct_devinfo* pDevInfo;
char nameB[BUFF_LEN];
char nameC[BUFF_LEN];
char buff[BUFF_LEN];
int dev;
int nr;
int err;
int line;
DX_IOTT* plott;
char nmC[1024];
int bd, ch;
int bdV, chV;
char* pChannel[BUFF_LEN];
long devBRD;
LINEDEV* pLineDev;
int nrChannels;
};
My code compiles fine, no errors what so ever. However, during runtime I get a error:
"The instruction at "0x00401614" referenced memory at "0x00000000". The memory could not be "written".
After putting in some debug code, to find out exactly what line the error happens, I found the violating line of code:
Code:
for (ch = 0; ch < nr; ch++)
{
wsprintf (name,"dxxxB%dC%d", bd+1, ch+1);
gBoardInfo[bd].pChannel[ch] = _strdup (name);
plott = &gBoardInfo[bd].plott[ch];
plott->io_type = 0; // <- Error Popup
plott->rfu = 0;
plott->io_fhandle = -1;
plott->io_bufp = NULL;
plott->io_offset = 0;
plott->io_length = 0;
plott->io_nextp = NULL;
plott->io_prevp = NULL;
}
The error happens right when I use plott to assign values.
The declaration of plott is:
The declaration of DX_IOTT is:
Code:
typedef struct dx_iott DX_IOTT;
/*
* DX_IOTT: I/O Transfer Table structure
*/
struct dx_iott {
unsigned short io_type; /* Transfer type */
unsigned short rfu; /* reserved */
int io_fhandle; /* File descriptor */
char *io_bufp; /* Pointer to base memory */
unsigned long io_offset; /* File/Buffer offset */
long int io_length; /* Length of data */
DX_IOTT *io_nextp; /* Pointer to next DX_IOTT if IO_LINK */
DX_IOTT *io_prevp; /* (optional) Pointer to previous DX_IOTT */
};
I am fresh out of ideas of how to resolve this. Can someone tell me what it is that I am doing wrong? I've been dabbling with this error for weeks now, trying to overcome it on my own.