|
Sorry, but without seeing your code I have no idea what to suggest, other than some careful reviewing of your code, and use of your debugger.
|
|
|
|
|
It's very bad idea to use the complex types from one DLL to another. Firstly your DLLs can use different "packing size". Secondly these STL types can use own allocators which can be different. Thirdly these STL types can be incompatible due to different realizations of STL.
With best wishes,
Vita
|
|
|
|
|
Could you please suggest me how can I make the packing size as same between COM and the DLL?
Kings
|
|
|
|
|
Check if the VS2008 project is 64bit while the VS2013 one is 32bit.
|
|
|
|
|
No, both the DLL and COM are compiled in VS2013 and are compiled as 32 bit binaries.
Kings
|
|
|
|
|
_SECURE_SCL was enabled in COM amounting to 4 byte increase in size. Removing that solved the issue.
Kings
|
|
|
|
|
I write a function like:
<pre lang="c++">
void func1(char chx[], int y)
{
int wsn = 0;
wsn = *(int *) (&chx);
if (wsn == 0) {
...
}
}
Compiler works well, no warning, no error. But when the code is running, seems it get a wild pointer. the code crashed.
|
|
|
|
|
Should be:
void func1(char chx[], int y)
{
int wsn = 0;
wsn = *(int *)chx;
if (wsn == 0) {
...
}
}
The variable name chx is already a pointer to the array, adding the addressof operator creates a pointer to that pointer.
|
|
|
|
|
Thanks, but I tested, &chx = chx.
|
|
|
|
|
No it doesn't. I have no idea how you tested this but it is not correct. Build the following, step through it with your debugger and you will see that they are different.
int* pAddressOf = (int *) (&chx);
int* pNormal = (int *)(chx);
|
|
|
|
|
I tested in Visual studio IDE.
char s1[] = {'H', 'e', 'l', 'l', 'o'};
printf("%lX,%lX",s1,&s1);
And I get same value for s1 and &s1.
|
|
|
|
|
And I tested your code in Visual studio, use Printf("%lX"),
It shows same value too
|
|
|
|
|
That may be true, but sending those values to printf is not the same as casting to pointers. You can confirm it by printing out the values of the two pointers created in my two lines of code.
|
|
|
|
|
|
Windows 7, Visual Studio 2008, C++
I am writing a TCP/IP utility that can be run/used by a non-windowing application. An MFC dialog stands in for the main app during development. The utility runs as a separate thread and communicates with the main app via events and a shared memory structure. Keeping this short:
Is there a mechanism that the TCP utility can use to trigger a method in the MFC?
Details
Presume the dialog has: OnBnClickedShowStatus(…) When the button is clicked this method reads some variables from the shared structure and displays them in the dialog. Can that button, or its essential code, be triggered by an event from the TCP utility?
The alternative is to create a timer and have it run every 300 milliseconds or so. I am hoping for something that is as simple as the timer and causes minimal additional coding in the TCP utility.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
A better solution would be to implement the TCP utility as a library that can be called from any other application: windows, non-windows, MFC or not. It could incorporate a call back feature that would allow it to call into the controlling app whenever necessary.
|
|
|
|
|
I don't have any idea of how to do that, but it sounds like a good concept. I did some searching and will look into that.
Still, finding this particular concept of having the thread call into the controlling app may be a bit difficult to discover. Can you give me a few words or a link that discusses that in particular?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 7-Sep-14 11:15am.
|
|
|
|
|
Export an API from the library that takes a function pointer as an argument. Then use this API from the main program to pass a function pointer into the library so it can call back to the main program.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I am having a bit of trouble with that concept. I am currently writing and testing this utility, a TCP/IP class that is run under a thread separate from the main app. The main app instantiates a class call C_Log_Writer to write data to a log file. Main handed a pointer to C_Log_Writer to the thread and it tried to write some data to the log. That crashed the app repeatedly. The prompted the conclusion that since they are in separate threads each with its own execution pointer, that was not a good idea.
Creating a new instance of C_Log_Writer for the thread resolved the problem. There are two log files, but that's okay. That makes me concerned that calling a function across a thread boundary might be a problem.
That said:
When you write: Export an API from the library, I take that to mean export a function from the TCP utility. Do I follow you correctly?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
1. Yes, export a function from the utility
2. About the crashing when passing a pointer to your log class: Where did it crash? Can you pinpoint that? It might have something to do with the TCP utility using a different heap from the main exe.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
please help me coding (in language C)quine mcCluskey's method for solving upto 8,9 or 10 variables whose minterms are to be generated automatically, only the no. of minterms, no.of variables and vectors of minterms are user given
|
|
|
|
|
And please do not repost the same question.
|
|
|
|
|
can someone plez help me coding the program in C for implementing Quine McCluskey's method for 8,9 or 10 variables where the inputs are to be generated automatically. Only the no. of variables, no. of minterms and a vector of minterms are user given.
|
|
|
|
|
|
Windows 7, Visual Studio 2010, C++
structure m_common_data contains:
struct st_common_data
{...
LPWSABUF p_lpwsabuf_array[ TCP_SERVER_PACKET_BUFFER_SIZE ];
where the constant has the value 16.
The main app dot H contains:
char m_send_buf_array[ TCP_SERVER_PACKET_BUFFER_SIZE ][TEST_BUFFER_SIZE];
where TEST_BUFFER_SIZE is an arbitrary 1024 for initial testing.
the main app dot CPP initializes all with this, and after some debugging variables were installed looks like this:
void CTest_ServerDlg::Initialize_Send_Buffers()
{
unsigned int db1, db2a, db2b, db2c, db2d, db3, db4, db5, db6, db7;
for( int i = 0; i < TCP_SERVER_PACKET_BUFFER_SIZE; i ++ )
{
for( int j = 0; j < TEST_BUFFER_SIZE; j ++ )
{
m_send_buf_array[ i ][ j ] = ( ( i * 5 ) + j ) % 255;
}
db1 = (unsigned int) &m_send_buf_array[ i ][0];
db2a = m_send_buf_array[ i ][0];
db2b = m_send_buf_array[ i ][1];
db2c = m_send_buf_array[ i ][2];
db2d = m_send_buf_array[ i ][3];
db3 = sizeof( m_send_buf_array[ i ] );
db4 = (unsigned int) &m_common_data;
db5 = (unsigned int) &( m_common_data.p_lpwsabuf_array[ i ] );
db6 = (unsigned int) &( m_common_data.p_lpwsabuf_array[ i ]->buf );
m_common_data.p_lpwsabuf_array[ i ]->buf = &m_send_buf_array[ i ][0];
m_common_data.p_lpwsabuf_array[ i ]->len = sizeof( m_send_buf_array[ i ] );
}
When stopped on the first time through the i loop, i = 0.
The debugger shows
db1 = a valid looking address
dba,b,c, and d contain: 0, 1, 2, 3, as expected
db3 = 0X400, expected
db4 looks like a valid address
db5 = db4 + 0xF0 again expected because of items not shown.
db6 shows the value 4.
db6 is the value I do not comprehend. I expected a valid address here, specifically I expected the value to be 4 larger than db5 because the ->buf item of structure WSABUF is the second item in the structure.
Please explain why db6 has the value 4 rather than the address of item ->buf.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 14-Aug-14 11:56am.
|
|
|
|