|
jeansea wrote: error C2668: “min”:
Not very usefull reply...
Anyway, you don't have the error when you run but when you compile then ? That's something completely different.
The problem probably comes from the fact that min already exists (I think). Try using another name or putting the function in a specific namespace.
|
|
|
|
|
oh....yes
i think you are right when i using another name is can run and no error
thanks
|
|
|
|
|
jeansea wrote: compiler error the message is
error C2668: “min”:
Let's be more accurate - that's part of the message...this is the message I get from your code:
error C2668: 'min' : ambiguous call to overloaded function
a.cpp(6): could be 'Type min<int>(Type,Type)'
with
[
Type=int
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xutility(3397): or 'const _Ty &std::min<int>(const _Ty &,const _Ty &)'
with
[
_Ty=int
]
while trying to match the argument list '(int, int)'
It helps when a) programming, or b) asking questions about programming, to get all the details correct and in place...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i want to put all detail messages but i the message show in chinese...
i know to put all error message next thank for tips
|
|
|
|
|
jeansea wrote: i want to put all detail messages but i the message show in chinese...
OK - I'll let you off - my Chinese reading skills are sadly lacking
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
jeansea wrote: but when i run the result is show wrong can somebode help me
Cédric Moonen wrote: What is the result you have and what did you expect ?
jeansea wrote:
compiler error the message is
error C2668: “min”:
TOO FUNNY!
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]
|
|
|
|
|
jeansea wrote: when i run the result is show wrong
When you run what?
As I expected, you get a compiler error when you try and compile that code, because the standard library already defines a template min function. You need to specify which min you want, by specifying that you want the 'no namespace' version (for that is yours) like this - oh, and you don't need to specify template parameters for functions if the function argument's types unambiguously specify the template parameters:
c = ::min(a, b);
Oh - and using namespace std; is bad form - use a using declaration instead. In your case, that would be 'using std::cout '. Those changes leave your program like this:
#include<iostream>
using std::cout;
template<typename Type>
Type min(Type a,Type b)
{
return a<b?a:b;
}
int main()
{
int a = 0, b = 1, c = 3;
c = ::min(a,b);
cout<<c;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Would you stop already? Whenever I want to answer some question here, your answer is already posted.
|
|
|
|
|
Sorry sir, I'll stop now
Actually, I'm going to be off t'Internet from Thursday till Monday, so if you could cover for me, that'd be good
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
So your creator has decided to turn off all the bots for a while? :P
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Just for a short time while we upgrade them to a cluster of Mac Pros rather than Mac Minis
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Welcome in the THHB [^], [^].
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]
|
|
|
|
|
Welcome in the THHB [^], [^]
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]
|
|
|
|
|
I tried using shared pointer in VS 2008 trial edition(Team suite) in a Win32 application,
#include "stdafx.h"
#include <memory>
int _tmain(int argc, _TCHAR* argv[])
{
std::tr1::hexfloat //Only this comes in tr1 namesspace
std::tr1::shared_ptr sharedPtr;
//std::tr1:: error C2039: 'shared_ptr' : is not a member of 'std::tr1'
return 0;
}
It’s supporting auto_ptr but not shared_ptr. Is the problem in my coding or because of trial version.
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
Could be the trial version - I seem to remember tr1 only got added to VS2008 in service pack 1 or with the Visual C++ 2008 Feature Pack[^].
Anyway - std::tr1::shared_ptr works fine for me on VS2008 with service pack 1 installed.
PS - you'll need to tell shared_ptr (as a template parameter) what type it's pointing at!!!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello I want to read from com port1, and I used API
if (WaitCommEvent(hSerial, &dwCommEvent,NULL))
{
if (dwCommEvent & EV_RXCHAR)
{
DWORD dwNumberBytesRead;
if(ReadFile(hSerial, chRead, sizeof(chRead),&dwNumberBytesRead,&osReader))
I have got an extra Thread to read com port but if data is not send to port my program hangs up.
Is there any way to check if input buffer is changed and then ReadFile instead waiting for
WaitCommEvent ??, or if there is some other ways?
Thanks in advace
|
|
|
|
|
komofilms77 wrote: ...or if there is some other ways?
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
When I've programmed serial ports, I've not used WaitCommEvent - I've set a timeout period with SetCommTimeouts [^] and just used ReadFile . If the serial port receives data or times out, then ReadFile returns successfully and will tell you how many bytes it received (0 probably indicates a timeout).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I want to convert a cstring into LPBYTE but each time i convert it only first character get stored in the LPBYTE and rest of the string is truncated.
Thanks
amit
|
|
|
|
|
First important point: why do you want to do such a thing ? Are you aware about unicode/non-unicode ? If not, I highly suggest reading this article[^] before going further.
Post also your code to see what you are doing wrong.
|
|
|
|
|
Hi .. thanks for prompt reply. I am getting a file in cstring and i want to parse. The parser take the data in LPBYTE format and file data contain few words in languge other than english thats why i am taking cstring to store it. But when i convert cstring to lpbyte only first character get stores. Meanwhile i am going through the link you have sent.
amit
|
|
|
|
|
amit.code wrote: I want to convert a cstring into LPBYTE...
How are you doing it? Something like:
CString name("Name");
const LPBYTE lp = (const LPBYTE) (LPCSTR) name; amit.code wrote: ...but each time i convert it only first character get stored in the LPBYTE and rest of the string is truncated.
How are you verifying this?
Is Unicode defined?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Yes .. i have also tried the method that you mentioned. I am parsing that whole data that comes in lpbyte but it shows only one character. During debugging I am verifying it also throughg watch window.
Thanks
amit
|
|
|
|
|
Could it be that you are feeding a unicode string to something that expects a simple ASCII string? Also note, that LPBYTE is porbably not recognized as a string by the debugger, thus it will only show you the pointer's value (the address it is pointing at) and maybe the one byte it is pointing at.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|