|
Hi,
there is a tool to generate wrappers to call C/C++ from PHP and other script languages called SWIG ( see: http://www.swig.org[^] ). I've used it a few times to generate wrappers for perl.
Hope this helps.
Frank
|
|
|
|
|
Hi Frank,
Can i use Zend library to do the same because i have done some rnd on it. so if u know anything about it yhen please let me know.
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
Hi,
Now I use a driver (first part of the code) - no changes possible.
I have to use something like a message processing and because I'm unable to use an array of the internal buffers of the driver -> I use more then 10 function with the same code.
here is my code
I would like to use a vector of messages (message0, message1 ..).
any other ideea is welcome of grouping these data types.
thanks
<pre>// Gateway_array.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType0;
typedef union
{
unsigned char _c[8];
msgType0 msg0_0;
} buf0;
buf0 message0;
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType1;
typedef union
{
unsigned char _c[8];
msgType1 msg0_1;
} buf1;
buf1 message1;
/// ................................
/// UP is the Driver .. No changes possible
// X 8 times
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType;
typedef union
{
unsigned char _c[8];
msgType msg;
} type_array;
type_array Vector[2]; // i would like to use a vector like this one
int main(int argc, char* argv[])
{
Vector[0] = message0; //error when using it
return 0;
}
</pre>
|
|
|
|
|
Why don't you define type_array as union of {buf1 , .., buf8 }?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi
with a union like this doesn't work either.
I get ..cannont convert buf0 to unsigned char.
typedef union
{
buf0 msg0;
buf1 msg1;
} type_Array;
type_Array Vector[]={message0 , message1};
if i put like this, works:
unsigned char x1;
unsigned char x2;
type_Array Vector[]={x1, x2};
//(this doesn't seem to be logic i should have here a vector of 8 unsigned chars)
so, the problem is
the compiler see message0 of type buf0, somehow cannot use union definition.
msgType0 and msgType1 are user defined types.
|
|
|
|
|
Why you want to assign a unsigned char to a msgType0 ? It looks more reasonable something like
msgType0 msg;
unsigned char x = 0x20;
msg.signal0 = x;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
yes, true
my problem is I cannot build the array with this code:
/// Driver
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType0;
typedef union
{
unsigned char _c[8];
msgType0 msg0_0;
} buf0;
buf0 message0;
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType1;
typedef union
{
unsigned char _c[8];
msgType1 msg0_1;
} buf1;
buf1 message1;
/// ................................
/// UP is the Driver .. No changed possible
// X 8 times
// seems logic to work with this code
typedef union
{
buf0 msg0;
buf1 msg1;
} type_Array;
type_Array Vector[]={message0 , message1};
so, I want to build an array of message0, message1....
not other data.
|
|
|
|
|
hi
the ideea was ok. my sintax was not
this code is ok:
// diff types array.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType0;
typedef union
{
unsigned char _c[8];
msgType0 msg0_0;
} buf0;
buf0 message0;
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType1;
typedef union
{
unsigned char _c[8];
msgType1 msg0_1;
} buf1;
buf1 message1;
/// ................................
/// UP is the Driver .. No changed possible
// X 8 times
int main(int argc, char* argv[])
{
printf("Hello World!\n");
typedef union
{
buf0 msg0;
buf1 msg1;
} type_Array;
type_Array X1;
type_Array X2;
X1.msg0= message0;
X2.msg1= message1;
type_Array Vector[2];
Vector[0]= X1;
Vector[1]= X2;
return 0;
}
|
|
|
|
|
hi
(again what I would like to have is an array of message0, message1...)
please give me a clue if any
I thought I solved it.. unfortunally I cannot refer the buffer I need.
I need message0._c[0] these buffer to refer to.
the only way is with sintax: Vector[0].msg0._c[0]=1; //ok // not usefull
i have to apppend .msg0 which is not usefull
// diff types array.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType0;
typedef union
{
unsigned char _c[8];
msgType0 msg0_0;
} buf0;
buf0 message0;
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType1;
typedef union
{
unsigned char _c[8];
msgType1 msg0_1;
} buf1;
buf1 message1;
/// ................................
/// UP is the Driver .. No changed possible
// X 8 times
int main(int argc, char* argv[])
{
printf("Hello World!\n");
union type_Array
{
buf0 msg0;
buf1 msg1;
} ;
type_Array X1;
type_Array X2;
X1.msg0= message0;
X2.msg1= message1;
type_Array Vector[2];
Vector[0]= X1;
Vector[1]= X2;
// what i would like to refer is this buffer message0._c[0]
message0._c[0]= 1;
Vector[0]._c[0]=1; //imposible to use because of refering msg0
//Vector[0].msg0._c[0]=1; //ok // not usefull
return 0;
}
modified on Thursday, January 21, 2010 11:34 AM
|
|
|
|
|
Why isn't it useful?
A dirty trick would be
union type_Array
{
unsigned char _c[8];
buf0 msg0;
buf1 msg1;
} ;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
isn't usefull either because I have to modify the driver. The upper section until // /// UP is the Driver .. No changes possible
// X 8 times
I cannot modify!
because of these individual buffers of the driver ... insted of writing a SINGLE! Processing message function - for all messaging (involving these individual buffers) (it is the same code) - I have a dozen function making same thing.
Inside them I refer to buffers like message0._c[(i=1,n)]= value; , next function message1._c[(i=1,n)]= value etc.
If i would have an ARRAY of message0, message1, I would write a single function.
with my previous code I would refer these buffers with Vector[0].msg0._c[0]=1; //ok // not usefull
But how do I put in the code line section msg0? the above line would be in a for.
Maybe I was more clear explaiing my problem this time.
I think the problem here is, basically I have a union inside a union.
|
|
|
|
|
Is the following snippet of MFC code similar to the DoEvents() functionality in Visual Basic?
MSG msg;
if(PeekMessage(&msg, AfxGetMainWnd()->m_hWnd, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
---
Hakuna-Matata
It means no worries for the rest of your days...
It's our problem free, Philosophy
"I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."
|
|
|
|
|
Its a long time ago I wrote a message loop but this looks good.
But do this in a while loop (because you should process all messages in the queue) till PeekMessage
returns 0 (so no more messages are available). And maybe you should process the WM_QUIT message.
Greetings
Covean
|
|
|
|
|
I don't know about all details of the DoEvents in VB but this code is doing something similar: it allows you to let the UI not freeze even if you are doing lenghty calculations.
But everything should be explained quite in details in the article I gave you.
|
|
|
|
|
I just looked what the DoEvents call does and it looks functionally similar to the loop you've written. But it's just that in this case you're translating and dispatching the messages yourselves, but in the VB case you'll be transferring control to the OS and it does the thing for you.
If you're going to use such a loop in your code, you may want to consider using a worker thread instead (but that really depends on what exactly are you trying to achieve).
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Rajesh R Subramanian wrote: I just looked what the DoEvents call does and it looks functionally similar to the loop you've written. But it's just that in this case you're translating and dispatching the messages yourselves, but in the VB case you'll be transferring control to the OS and it does the thing for you.
This is not true: even in VB, the VB-runtime does the thing for you and not the OS.
What happens is that the message-queue is dispatched till it is empty. From that point Windows can give its time to others. 'Transferring control to the OS" then means giving the time you don't need because the queue is empty, back to the OS.
Rajesh R Subramanian wrote: If you're going to use such a loop in your code, you may want to consider using a worker thread instead (but that really depends on what exactly are you trying to achieve).
Actually that would make things worse: every thread has its own message-queue.
Rozis
modified on Monday, January 18, 2010 5:56 PM
|
|
|
|
|
Rozis wrote: This is not true: even in VB, the VB-runtime does the thing for you and not the OS.
While I know nothing about VB, this is from the docs of the said function: DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent. So, the documentation could be wrong.
Rozis wrote: Actually that would make things worse: every thread has its own message-queue.
What an ignorant statement! Every thread won't have its own message queue. A thread will have a message queue only if it's an UI thread!
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">Rajesh R Subramanian wrote:</div>While I know nothing about VB, this is from the docs of the said function: DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent. So, the documentation could be wrong.</blockquote>
The documentation is not wrong. It states exactly - in other words - my point.
<blockquote class="FQ"><div class="FQA">Rajesh R Subramanian wrote:</div>What an ignorant statement! Every thread won't have its own message queue. A thread will have a message queue only if it's an UI thread! </blockquote>
I'm sorry: of course you are right. But the problem was: is it a good idea to move the dispatcher to another thread. I think not because 1) there's not performance gain, 2) it complicates the dispatcher, and 3) if he makes a mistake it's reading the wrong message-queue.
The initial question was: is the dispatcher written equivalent to the VB DoEvents. In my opinion it is an exact copy. I believe in this situation introducing an extra thread has no meaning, but i'll be pleased to be convinced by you. The statement was not a lack of knowledge from my side but I thought your answer got of the track of the initial question. I'm really sorry if i offended you: that was not my intention.
As Pallini pointed out: although threads will not initially have a message-queue, they will if you use any of the message-functions. So my question to you is how would you create a thread with a dispatcher that dispatches the message-queue of another thread? I simply don't get it. If you move the code of the dispatcher to another thread it will dipatch the thread's queue and not the queue of your main program.
Rozis
|
|
|
|
|
Rozis wrote: every thread has its own message-queue.
True: though on 16-bit Windows [^]...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I tried with win32 dialog..woking fine with button and list control but when I place a tab control or tree control...dialog does not appear but runs behind.
What might be the problem?
|
|
|
|
|
adjust the positions of all child control properly
|
|
|
|
|
Could someone direct me to a resource on threading for C++? I am familiar with threading but I would like to learn more about thread synchronization, UI Threads, Updating UI via worker threads, etc. Also, I would also like to learn about memory profiling and finding memory leaks in the code. Any kind of help would be deeply appreciated.
Also, is it ok to update the UI of a dialog from a worker thread using SendMessage/PostMessage? How do I handle multiple worker threads making changes to the same UI?
Thank You.
---
Hakuna-Matata
It means no worries for the rest of your days...
It's our problem free, Philosophy
"I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."
|
|
|
|
|
Here[^] is one of the best article I've read about threading. It will answer a lot of your questions.
|
|
|
|
|
|