Array of Variables
-
I have been trying to store away an array of variables that I wish to display via a general display routine (i.e. deal with any type of variable). e.g.
typedef struct { void* data [10][20][20]; DATA_DETAILS dataDetails[10][20][20]; short feildsInDisplay [10][20]; }DISPLAY_DB; DISPLAY_DB myDB; // Store away the addresses of the display data items myDB.feildsInDisplay[0][0] = 2; myDB.data[0][0][0] = &(shortInteger1); myDB.dataDetails[0][0][0] = short_integer_details; myDB.data[0][0][1] = &(float_data_item); .
etc At some point later in the program// Now get the data for display dataStr.Format ("%d", myDB.data[0][0][0]) ; strName = myDB.dataDetails[0][0][0].fieldDesc; m_cEditTest.SetWindowText (strName + dataStr);
What I get is the correct dataDetails but the address of the data not the data itself. How do I dereference this data. e.g. Test Data 1 = 438181 and not Test Data 1 = 1234 If I trydataStr.Format ("%d", *myDB.data[0][0][0]);
I get an illegal indirection error. Also I cannot store away the address of bit fields I get the following errors c:\Export_LibDlg.cpp(479): error C2104: '&' on bit field ignored c:\Export_LibDlg.cpp(549): error C2100: illegal indirection where the data isunsigned dataBit : 4; myDB.data[0][0][0] = &(dataBit);
Any suggestions, grahamfff -
I have been trying to store away an array of variables that I wish to display via a general display routine (i.e. deal with any type of variable). e.g.
typedef struct { void* data [10][20][20]; DATA_DETAILS dataDetails[10][20][20]; short feildsInDisplay [10][20]; }DISPLAY_DB; DISPLAY_DB myDB; // Store away the addresses of the display data items myDB.feildsInDisplay[0][0] = 2; myDB.data[0][0][0] = &(shortInteger1); myDB.dataDetails[0][0][0] = short_integer_details; myDB.data[0][0][1] = &(float_data_item); .
etc At some point later in the program// Now get the data for display dataStr.Format ("%d", myDB.data[0][0][0]) ; strName = myDB.dataDetails[0][0][0].fieldDesc; m_cEditTest.SetWindowText (strName + dataStr);
What I get is the correct dataDetails but the address of the data not the data itself. How do I dereference this data. e.g. Test Data 1 = 438181 and not Test Data 1 = 1234 If I trydataStr.Format ("%d", *myDB.data[0][0][0]);
I get an illegal indirection error. Also I cannot store away the address of bit fields I get the following errors c:\Export_LibDlg.cpp(479): error C2104: '&' on bit field ignored c:\Export_LibDlg.cpp(549): error C2100: illegal indirection where the data isunsigned dataBit : 4; myDB.data[0][0][0] = &(dataBit);
Any suggestions, grahamfff -
I have been trying to store away an array of variables that I wish to display via a general display routine (i.e. deal with any type of variable). e.g.
typedef struct { void* data [10][20][20]; DATA_DETAILS dataDetails[10][20][20]; short feildsInDisplay [10][20]; }DISPLAY_DB; DISPLAY_DB myDB; // Store away the addresses of the display data items myDB.feildsInDisplay[0][0] = 2; myDB.data[0][0][0] = &(shortInteger1); myDB.dataDetails[0][0][0] = short_integer_details; myDB.data[0][0][1] = &(float_data_item); .
etc At some point later in the program// Now get the data for display dataStr.Format ("%d", myDB.data[0][0][0]) ; strName = myDB.dataDetails[0][0][0].fieldDesc; m_cEditTest.SetWindowText (strName + dataStr);
What I get is the correct dataDetails but the address of the data not the data itself. How do I dereference this data. e.g. Test Data 1 = 438181 and not Test Data 1 = 1234 If I trydataStr.Format ("%d", *myDB.data[0][0][0]);
I get an illegal indirection error. Also I cannot store away the address of bit fields I get the following errors c:\Export_LibDlg.cpp(479): error C2104: '&' on bit field ignored c:\Export_LibDlg.cpp(549): error C2100: illegal indirection where the data isunsigned dataBit : 4; myDB.data[0][0][0] = &(dataBit);
Any suggestions, grahamfff -
I have been trying to store away an array of variables that I wish to display via a general display routine (i.e. deal with any type of variable). e.g.
typedef struct { void* data [10][20][20]; DATA_DETAILS dataDetails[10][20][20]; short feildsInDisplay [10][20]; }DISPLAY_DB; DISPLAY_DB myDB; // Store away the addresses of the display data items myDB.feildsInDisplay[0][0] = 2; myDB.data[0][0][0] = &(shortInteger1); myDB.dataDetails[0][0][0] = short_integer_details; myDB.data[0][0][1] = &(float_data_item); .
etc At some point later in the program// Now get the data for display dataStr.Format ("%d", myDB.data[0][0][0]) ; strName = myDB.dataDetails[0][0][0].fieldDesc; m_cEditTest.SetWindowText (strName + dataStr);
What I get is the correct dataDetails but the address of the data not the data itself. How do I dereference this data. e.g. Test Data 1 = 438181 and not Test Data 1 = 1234 If I trydataStr.Format ("%d", *myDB.data[0][0][0]);
I get an illegal indirection error. Also I cannot store away the address of bit fields I get the following errors c:\Export_LibDlg.cpp(479): error C2104: '&' on bit field ignored c:\Export_LibDlg.cpp(549): error C2100: illegal indirection where the data isunsigned dataBit : 4; myDB.data[0][0][0] = &(dataBit);
Any suggestions, grahamfffGrahamfff wrote: Also I cannot store away the address of bit fields That's correct. This is prohibited by the C standard. This is simply because if the field starts part-way through a byte, there is no way the compiler can take its address - it has to be on a byte boundary.
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"