|
The do/while is there to provide a block. Without the do/while, this code:
if (somefunc())
R(a,b,c); wouldn't give the right behavior because only the first statement would be inside the if block.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
but it could have provided these instructions into a block ( { } ) without do/while...
#define R(l,r,i) { l ^= p[i]; r ^= F(l); }
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
-- modified at 4:49 Wednesday 8th February, 2006
|
|
|
|
|
Not in all cases. Here's two versions of a macro:
#define FOO1(n) { return n; }<br />
#define FOO2(n) do { return n; } while(0)
Now given these two macros this will not complile:
if ( 1 )
FOO1(1);
else
return 0;
But this will:
if ( 1 )
FOO2(1);
else
return 0;
So there is method to the madness.
Steve
|
|
|
|
|
oh, my mistake...
yeah, the problem comes from the ; following the expansion of the macro...
a ; cannot come just after a } (except in a user-defined type definition - class, struct, enum, union...)
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
Hello experts,
I am writing an application in Solaris, which is supposed to work on PrimePower 650 and SunFire 440 machines. The application listens to the events raised by the Hardware and OS in /dev/log. The application listens to the messages logged into /dev/log and do some processing on them. Now, when there is a load condition occuring at /dev/log(i.e. number of messages per second ocurring at /dev/log is high), CPU consumption by my application shoots up to 50%, while my application is expected to consume not more than 1% CPU.
Now, I want to bring down the CPU consumption to 1%. Since the CPU consumtion can vary according to various CPU configurations, i have to ensure that the CPU consumption remains below 1% for low end CPUs.
Thanks in advance.
Currently to solve this problem, i am using the following technique:
1.Process is only reading 5 messages per second from /dev/log and process them. The process sleeps for rest of the time per second.
2. Every 100 messages, the process sleeps for 5 seconds.
This solution brings down the CPU consumption. On some CPU configurations, it is less than 1% CPU consumption. But on others still varies from 3-13%.
Please tell me if the processing delay technique used has some fundamental faults, or what is the correct technique of introducing processing delay for controlling CPU consumption.
Please also tell your suggestions for controlling CPU consumption. I would also appreciate , if you can redirect me to some links where i can find CPU consumption control techniques and fundamentals.
Thanks and regards.
|
|
|
|
|
And cross-posting to multiple forums is considered very rude! Come on, you posted this question in the "Article Requests and Ideas" forum...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi
i am tryin to write a program(personal interest) which generates the strings of length 5 with a given input of 2 strings from a set of strings.
that is, we have 26 alphabets and the input is "a b".
and my desired output should be "a b c d e"(length =5)
and all possible combinations with "a b - - -".
and also output should not contain "a b d c e" if it has "a b c d e".
can anyone help me the loop.
thanking you.
|
|
|
|
|
Consider a library (unmanaged) exports a class. the class is as follows.
class A<br />
{<br />
public:<br />
virtual void funcA()<br />
{<br />
}<br />
<br />
void DoProcessing()<br />
{<br />
funcA();<br />
}<br />
}
Now in native, If i have to override funcA it would be as
class DA : public A<br />
{<br />
public:<br />
virtual void funcA()<br />
{<br />
}<br />
}
Now if i create an object of DA, and call DoProcessing() , funcA() in DA would be called.
Now if I write a managed wrapper over class A as
class _gc MngdA<br />
{<br />
private:<br />
A __nogc* m_pA;<br />
public:<br />
void DoProcessing()<br />
{<br />
m_pA->DoProcessing();<br />
}<br />
}
No if I inherit from MngdA, i dont have any path to override the virtual functions. This means DoProcessing() will always call the funcA() in class A.
I need a mechanism, so that this virtual function call from the native could could be riuted out into managed code and be able to override it from clr languages.
|
|
|
|
|
Well, C++/CLI also has virtual functions. As long as your managed wrappers also have the same inheritance hierarchy.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I think u dint got my question right.
I have updated the question with further explanation if u could plz have a look.
Rahim Rattani
Karachi - Pakistan
|
|
|
|
|
You'd need managed wrappers for both base and derived classes for this particular scenario.
Regards,
Nish
|
|
|
|
|
|
48d2058 wrote: I was wondering if you'd mind finishing this project before 11/2/2006.
ROTFL. This is great.
1. You asked in the C++/CLI forums, your lecturer does not want a managed solution.
2. For you to get to the point of being asked to do this assignment, you must have had a class or two. Where you asleep ?
3. I will do this for you, for $200. I'll charge $400 for the next piece of homework you can't do because you didn't do this one. And my price will continue to double until you go broke, or until you graduate as an unemployable, lazy bum.
Or, you could try to do your own homework and ask specific questions. Then I will help for free.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: I will do this for you, for $200.
Damnit CG, stop reducing hour rates. I was gonna ask him for $400!
Regards,
Nish
|
|
|
|
|
LOL - you've got a point. I'll let all my various project managers know that I won't work for less than $400 an hour, from now on. :P
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
Im new to codeproject, I was hoping to get some help. Im tryin to convert the Image into Byte stream and send it to MySQL database. (Hence, so I can send image to database)
MemoryStream^ mst = gcnew MemoryStream();
viewPictureBox->Image->Save(mst,viewPictureBox->Image->RawFormat);
Byte BinaryImg[] = mst->GetBuffer(); <- doesnt like this line
MySqlCommand^ cmd = gcnew MySqlCommand("SELECT * FROM Patient", Mycon);
cmd = gcnew MySqlCommand("INSERT INTO patient(Leftimage) VALUES" + "('"+viewPictureBox+"')", Mycon);
I get the following error:
error C2440: 'initializing' : cannot convert from 'cli::array ^' to 'unsigned char []'
Im using MC++.
Can someone plz give me hand. I was informed that Nish can help me with this porblem !
thanks alot in advance
hbjs
makaveli
-- modified at 21:10 Sunday 5th February, 2006
|
|
|
|
|
Hi
can someone please give me a comment or advice as Im stuck!!
thanks
makaveli
|
|
|
|
|
The MSDN[^] documentation says GetBuffer returns array<unsigned char>^ , did you try using that?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
-- modified at 0:42 Monday 6th February, 2006
|
|
|
|
|
Hi Senthil,
MemoryStream^ mst = gcnew MemoryStream();
viewPictureBox->Image->Save(mst,viewPictureBox->Image->RawFormat);
//Byte BinaryImg[] = mst->GetBuffer(); <- doesnt like this line
array<unsigned char="">^ GetBuffer();
MySqlCommand^ cmd = gcnew MySqlCommand("SELECT * FROM Patient", Mycon);
cmd = gcnew MySqlCommand("INSERT INTO patient(Leftimage) VALUES" + "('"+mst+"')", Mycon);
It compiles, but it says it entered system.IO.MemoryStream !!
Im assuming it wasnt inserted correctly. Can u please tell me how to insert it in my code correctly and in the MySQL statement.
Many thanks for your help
regards
hbjs
makaveli
-- modified at 1:14 Monday 6th February, 2006
|
|
|
|
|
Hi Senthil,
MemoryStream^ mst = gcnew MemoryStream();
viewPictureBox->Image->Save(mst,viewPictureBox->Image->RawFormat);
//Byte MEDIUMBLOB= System::Char::Encoding::UTF8; // mst->GetBuffer();
cli::array<unsigned char="">^ BinaryImg = mst->GetBuffer();
It compiles ! MySQL doesnt except it like that so I need to convert Hex I think, still researching.
thanks for ur help
Regards
makaveli
|
|
|
|
|
I need somewhere to help me figure out how to store hex values. I dont think you can store the hex values as hex, but would it be possible to convert decimal values to hex values and convert the hex values to ascii values and store the ascii values as integers. If someone has an easier way let me know. Thanks
|
|
|
|
|
What are you trying to do ? Hex values and decimal values make non-sense. A value is a value and that's it. The only thing that can change is the way you REPRESENT your value: either in a decimal format, or in an haxadecimal format, ... Now, if you want to print your value in an hexadimal representation, just use sprintf, something like that:
int Value = 2000;<br />
char StringVal[50];<br />
sprintf(StringVal,"%x",Value);
|
|
|
|
|
If he is talking about storing base-10 numbers as base-16 in a text-base file such as XML, then he would reduce the size of the file at the cost of the overhead of the conversion. If the storage is a relational database then the conversion would be a waste of time.
If he is talking about storing "System::Decimal" numbers, then there is a different set of issues.
-- modified at 16:06 Friday 3rd February, 2006
|
|
|
|
|
hi,
does anybody know a function to store a registry key and value to a .reg file and an other function to restore the data of this file if necessarry ?
thanks for help
best regards
emmi
|
|
|
|
|
Hey howzit?
I downloaded source code from this artcle: http://www.codeproject.com/internet/SendTo.asp
I am not sure if its C++ code or C++.NET code but I have no idea how to even begin to compile it, but I really need to see how it works.
I have opened the file in VS 2005, what do I do now, please help, I am a newbie!
|
|
|
|