|
My untested guess would be
#define TestMacro2(x) _asm{ mov eax, 0 \
mov ebx, 0 }
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
When I try to compile this:
#define TestMacro2(x) _asm{ mov eax, 0 \
mov ebx, 0 }
int main() {
TestMacro2(0);
return 0;
}
I get the following error and warning with VC++:
warning C4405: 'mov' : identifier is reserved word<br />
error C2400: inline assembler syntax error in 'second operand'; found 'register'
Thanks anyway
Aidman » over and out
|
|
|
|
|
I am sorry Aidman that it didn't work. It was just a suggestion that I didn't test, because I was in a hurry.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Nope. Won't work. The '\' at the end of the line will cause the two lines to be concatenated, effectively becoming
#define TestMacro2(x) _asm{ mov eax, 0 mov ebx, 0 } You'll have to use PJ's solution to get the result he's after.
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"
|
|
|
|
|
It was a shot in the dark. In assembly there are no line delimiters such as ; (I am sure you know this), while PJ's solution seemed to work I thought he could give it a try with my idea. Obviously, it doesn't work.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
The __asm is its own separator, so __asm mov ax,0 __asm mov bx,0 is perfectly valid code.
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"
|
|
|
|
|
Hi,
Did you try:
#define TestMacro2(x) { _asm mov eax, 0 _asm mov ebx, 0 }
or even
#define TestMacro2(x) { \
_asm mov eax, 0 \
_asm mov ebx, 0 \
}
Both of the above should work - note the surrounding braces {} are not necessary but are there to make the code look prettier.
HTH
--------------------------------------------
"The mere act of drinking beer in an attempt to measure your tolerance is likely to affect your impression of how many beers you've drunk."
-- The Heineken uncertainty principle.
|
|
|
|
|
see:
http://www.codeproject.com/script/comments/forums.asp?msg=550923&forumid=1647#xx550923xx
and
http://www.codeproject.com/script/comments/forums.asp?msg=549039&forumid=1647#xx549039xx
now my test result is :
the clean app works, but the clean DLL does not.
a good man
|
|
|
|
|
Hello all
I'm coding an application using CPropertySheet and adding some property pages to this property sheet. The problem the Apply button by default is disabled, is there any way to enable it for all the property pages contained in the property sheet.
If any one knows how to do it, pls help me.
thanks for your time.
Hari.
|
|
|
|
|
From my copy of MSDN
CPropertyPage::SetModified() Call to activate or deactivate the Apply Now button.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hi Andrew
Thanks for the reply. Now the Apply button is activated whenever I change any of the Page properties.
Thanks for answering my question.
Hari.
|
|
|
|
|
That's ok.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
i need to send a UDP broadcast message to a network of sensors, and i'm trying to use the CAsyncSocket class. the sensors are accepting text string commands on port 7000. here's the code:
<br />
int errorCode;<br />
<br />
if (!m_udpSocket.Create(0, SOCK_DGRAM))<br />
{<br />
AfxMessageBox("Create Error");<br />
errorCode = GetLastError();<br />
}<br />
<br />
if (m_udpSocket.SendTo("xxxxx", sizeof("xxxxx"), 7000) == SOCKET_ERROR)<br />
{<br />
AfxMessageBox("Send Error");<br />
errorCode = GetLastError();<br />
}<br />
<br />
m_udpSocket.Close();<br />
the Create() function is working, but SendTo() gives me an error. the errorCode is 0, but this doesn't seem to match any of the winsock codes on MSDN. am i missing something or leaving something out? i don't know much about networking, but i have to use UDP and the sensors don't support CArchives so i can't use CSocket. any help is greatly appreciated!
(p.s. -- if there is a syntax error or something, it's probably just my typing - i don't have my hands on the actual code atm.)
|
|
|
|
|
replace sizeof("xxxxx") with strlen("xxxxx") , and if it still doesn't work try to put this line before SendTo() .
int on = 1, optlen = sizeof(on);
m_udpSocket.SetSockOpt(SO_BROADCAST,&on,optlen);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
thanks, that answered my question perfectly!
|
|
|
|
|
i'm having the same problem now with a tcp send.
<br />
if (Connect(host, 9000) == SOCKET_ERROR)<br />
{<br />
AfxMessageBox("Error Connecting");<br />
errorCode = GetLastError();<br />
}<br />
if (Send(command, command.GetLength()) == SOCKET_ERROR)<br />
{<br />
AfxMessageBox("Error Sending Packet");<br />
errorCode = GetLastError();<br />
}<br />
the Connect() seems to work, but i get an error sending. again, the errorCode is 0. is there another option i need to set? thanks, again.
|
|
|
|
|
Hi,
i'm developing this app using MFC now i want to store some functions(MFC),controls(MFC) ect. in a dll,
i have 2 options
Regular DLL using shared MFC or MFC extension DLL
wich is better to use and what is the difference beetwen them,
thanks
~dzenan~
|
|
|
|
|
Hi:
Regular DLL: Allows you to use any MFC classes and functions, but you can only exports "C" functions.
MFC extension DLL: Allows you to export Classes that you can derive from in your client app.
hope it helps
regards
Daniel Cespedes
"There are 10 types of people, those who understand binary and those who do not"
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
Thanks, that's the answer i was lookig for.
~dzenan~
|
|
|
|
|
I have a COm framework where I have two classes A and B that service requests based on their respective queues .
for e.g life Sequence for Class A is as follows :
1.Class A object created
2.AddedToQueue_A event created as nonSignalled .
3.Worker thread within Class A created .
4.CLass A QUEUE is empty hence Worker thread is blocked with the call:
ResetEvent(AddedToQueue_A)<br />
WaitForSingleObject(AddedToQueue_A,INFINITE);
5. When a request is added to Queue(Enqueue) a call is made to awaken the thread like :
SetEvent(AddedtoQueue_A);
6. Thread A is awakened and the request is serviced .
Similar is the case of Class B object
Observations :
1. With Class A object present and when there is no Class B object the thread is awakened properly and the queue is serviced .
2. With Class A and CLass B objects present , the observation is that though an entry is added to the Queue of class A , Class A thread is not getting awakened everytime for some reason .the thread gets awakened every alternated time when the Queue size =2;
My question is that is the blocking statement
WaitForsingleObject() associated with the thread priority . Why isnt Class A's thread being called everytime I Set the event while enqueuing ?
|
|
|
|
|
I don't entirely get your design, but I guess it doesn't matter, because:
ResetEvent(AddedToQueue_A)
WaitForSingleObject(AddedToQueue_A,INFINITE); is fundamentally flawed. Let me explain. Suppose a request is enqueued into A when worker thread A is servicing a prior request and before it has completed to do so. When the worker thread fininshes, it resumes waiting, but before that it calls ResetEvent(AddedToQueue_A) : the signal is lost and the thread sits here waiting for ever (or until another request with more lucky timing gets in).
Instead, create AddedtoQueue_A as automatic (see the docs for CreateEvent ) and do not use ResetEvent . Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you for your insight .
I made the modification but still find that my thread (Class A)gets awakened every alternate request (i.e Queuesize=2) . This behaviour is absent when the other thread of class B is absent .
here is a snippet of my thread operation
while(threadNeedstorun){<br />
if(queueSize>0){<br />
}<br />
WaitForSingleObject(AddedtoQueue_A,INFINITE)<br />
}<br />
<br />
here is the snippet of my Enqueue operation <br />
<br />
if(queueSize<MAX_QUE_SIZE){<br />
<br />
array[(head+queueSize)%MAX_QUE_SIZE]=newVal;<br />
queueSize++;<br />
<br />
SetEvent(AddedtoQueue_A) <br />
}<br />
|
|
|
|
|
OK, this kind of stuff is always somewhat messy. Try this. Define a CRITICAL_SECTION , say CS_A (don't forget to initialize it with InitializeCriticalSection ), create AddedtoQueue_A as manual and use the following for incrementing and decrementing the number of elements in the queue:
void DecrementElementsInA()
{
EnterCriticalSection(CS_A);
--queueSize;
if(queueSize==0){
ResetEvent(AddedtoQueue_A);
}
LeaveCriticalSection(CS_A);
}
IncrementElementsInA()
{
EnterCriticalSection(CS_A);
++queueSize;
if(queueSize>0){
SetEvent(AddedtoQueue_A);
}
LeaveCriticalSection(CS_A);
} Think this sould do. Please report back, regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I may be making a rash statement here, but this looks like a job for a semaphore, rather than an event.
Create a semaphore with an initial count of 0 and a huge max count (LONG_MAX or something like that). Each time a writer puts something in the queue, it calls ReleaseSemaphore. The reader(s) wait on the semaphore and remove one item from the queue each time they wake up.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
Hi,
I was told to run these lines of code in order to instantiate a class I have that is derived from CFrameWnd (CLogViewFrame):
<br />
CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CLogViewFrame );<br />
CObject* pObject = pRuntimeClass->CreateObject();<br />
ASSERT( pObject->IsKindOf( RUNTIME_CLASS( CLogViewFrame ) ) );<br />
It compiles nice, but now, how do I access my class, how do I reach it's methods ? Non of the pointer created, can lead me to my class.
Shay
|
|
|
|