|
Thanks Matthew,
I do not quite understand your sample below. Could you show some pseudo code please? Code clarifies everything.
Matthew Faithfull wrote: For example when matching template
parameters so int myfunc is the same function as int myfunc in some circumstances but not
in others.
regards,
George
|
|
|
|
|
Sorry George the template parameters got dropped, very .
what I meant was older MS compilers get int myfunc<const int> confused with int myfunc<int> and similar. Except that in some cases they get it right so it's very difficult to know exactly what will work and what won't.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks Matthew,
I think you mean something like this? I have tested in Visual Studio 2008, it will result in compile error,
error C2995: 'int myfunc(T)' : function template has already been defined
template <class T> int myfunc (T a) {};
template <class T> int myfunc (const T a) {};
regards,
George
|
|
|
|
|
Yes, that's another case of the same thing. It looks like they still haven't fixed it properly
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hi Matthew,
In your mind, you mean they will be treated as different thing? Does C++ Spec mention this?
regards,
George
|
|
|
|
|
actually, this is not problem / bug. They have reasons to do that.
This is because, how initializers can be used.
int myfunc (int );
int myfunc (const int);
myfunc (100); refers to which one?
"They are considered the same because they take the same initializers." from msdn.
compiler determine the corresponding overloaded function, according to the actual parameter type in the function call.
while
int myfunc (int & a);
int myfunc (const int &a); are different as the initializers are unique.
And VS2008 chooses to ignore overrided qualifiers conforming to ISO C++, may be its behaviour is undefined before in C++. And where ever undefined is in standards, implementation takes its own choice.
modified on Wednesday, February 27, 2008 1:23 AM
|
|
|
|
|
Hi Rajkumar,
For your sample,
int myfunc (int a);
int myfunc (const int &a);
even if they are different, they will result in ambiguity in function call. Right? Here is my below code and related compile error message. So, is there any practical benefits to define them both?
int myfunc (int a) {return 100;}
int myfunc (const int &a) {return 200;}
int main()
{
myfunc (100);
return 0;
}
Compile errors
1>d:\visual studio 2008\projects\test_const5\test_const5\main.cpp(7) : error C2668: 'myfunc' : ambiguous call to overloaded function
1> d:\visual studio 2008\projects\test_const5\test_const5\main.cpp(3): could be 'int myfunc(const int &)'
1> d:\visual studio 2008\projects\test_const5\test_const5\main.cpp(1): or 'int myfunc(int)'
1> while trying to match the argument list '(int)'
regards,
George
|
|
|
|
|
yes, you are right, i corrected my typo error.
And I assume ambiguity is the generic case of the same issue iam discussed.
|
|
|
|
|
Thanks Rajkumar,
My question is answered.
regards,
George
|
|
|
|
|
I've been wondering why my recent article 'How To Calculate The Age Of A File' has been getting poor votes. I wondered if the fact that I hadn't used the 'HighPart' and 'LowPart' members of the ULARGE_INTEGER was bad. Then again is my use of the following code bad?
SystemTimeToFileTime (& NowSystemTime, (FILETIME *) & ulSysTime);
SystemTimeToFileTime (&FileSystemTime, (FILETIME *) & ulFileTime);
Since posting my article, I have read 'Date and Time in C++' by RK_2000 and noted that he said
<quote>
Although [FILETIME and LARGE_INTEGER] have the same binary format, the address of all FILETIME structures must begin on a 32 bit boundary whereas the address of all LARGE_INTEGER must begin on 64 bit boundary. So, do not use these interchangeably.
... so this cast I've been using is wrong, then?
In the meantime, I will assume that this is a flaw that people have spotted in my code and rewrite it without this cast.
Thanks for your help,
Ben.
|
|
|
|
|
Ben Aldhouse wrote: I've been wondering why my recent article 'How To Calculate The Age Of A File' has been getting poor votes.
Because if people have the ability to vote low, then for no other reason, they will. Ignore the vote and move on.
Ben Aldhouse wrote: ...I will assume that this is a flaw that people have spotted in my code...
Doubtful. A truly interested and worthy reader will let you know.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks, David, for your encouraging reply.
I have tried the code without the cast and I can't get sensible results.
This is what I now have...
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(strPath, &FindFileData);
CString strYears, strMonths, strDays;
SYSTEMTIME stNow;
GetSystemTime(&stNow);
const FILETIME ftFile = FindFileData.ftCreationTime;
FILETIME ftNow;
ULARGE_INTEGER ulNowTime, ulFileTime, ulAge;
SystemTimeToFileTime (& stNow, &ftNow);
ulNowTime.HighPart = ftNow.dwHighDateTime;
ulNowTime.LowPart = ftNow.dwLowDateTime;
ulFileTime.HighPart = ftFile.dwHighDateTime;
ulFileTime.LowPart = ftFile.dwLowDateTime;
ulAge.HighPart = ulNowTime.HighPart - ulFileTime.HighPart;
ulAge.LowPart = ulNowTime.LowPart - ulFileTime.LowPart;
FILETIME ftAge;
SYSTEMTIME stAge;
ftAge.dwHighDateTime = ulAge.HighPart;
ftAge.dwLowDateTime = ulAge.LowPart;
SystemTimeToFileTime(&stAge,&ftAge);
strYears.Format("%d", stAge.wYear-1601);
strMonths.Format("%d",stAge.wMonth-1);
strDays.Format("%d",stAge.wDay-1);
I'm foxed. I should really take your advice and move on...
Ben.
|
|
|
|
|
What exactly is this code snippet supposed to be doing?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I was trying to find the difference between a file's creation date, the current time and get the resulting data in a useful format. Doing this I was aware of the following warning from the MSDN library
Remarks
It is not recommended that you add and subtract values from the SYSTEMTIME
structure to obtain relative times. Instead, you should
-Convert the SYSTEMTIME structure to a FILETIME structure.
-Copy the resulting FILETIME structure to a ULARGE_INTEGER structure.
-Use normal 64-bit arithmetic on the ULARGE_INTEGER value.
However, I think at this point I was put off because the promised 'HighPart' and 'LowPart' members of ULARGE_INTEGER didn't appear in the autocomplete list on my editor. I have since written in the members anyway and found that they work without any trouble.
Since your last reply I have had a walk around the block and had another look at the code. I discovered that when I was removing some lines whilst taking out the code that used that (FILETIME *)&ULARGE_INTEGER cast, I removed one line I should have left in and edited and left in another line towards the end of the code that should have been removed...
Here is the (now, at last) working code with comments.
Thanks for your encouragement and for showing an interest,
Ben
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(strPath, &FindFileData);
CString strYears, strMonths, strDays;
SYSTEMTIME stNow;
GetSystemTime(&stNow);
const FILETIME ftFile = FindFileData.ftCreationTime;
FILETIME ftNow;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(strPath, &FindFileData);
CString strYears, strMonths, strDays;
SYSTEMTIME stNow;
GetSystemTime(&stNow);
const FILETIME ftFile = FindFileData.ftCreationTime;
FILETIME ftNow;
SystemTimeToFileTime (& stNow, &ftNow);
ULARGE_INTEGER ulNowTime, ulFileTime, ulAge;
ulNowTime.HighPart = ftNow.dwHighDateTime;
ulNowTime.LowPart = ftNow.dwLowDateTime;
ulFileTime.HighPart = ftFile.dwHighDateTime;
ulFileTime.LowPart = ftFile.dwLowDateTime;
ulAge.HighPart = ulNowTime.HighPart - ulFileTime.HighPart;
ulAge.LowPart = ulNowTime.LowPart - ulFileTime.LowPart;
FILETIME ftAge;
SYSTEMTIME stAge;
ftAge.dwHighDateTime = ulAge.HighPart;
ftAge.dwLowDateTime = ulAge.LowPart;
FileTimeToSystemTime(&ftAge,&stAge);
strYears.Format("%d", stAge.wYear-1601);
strMonths.Format("%d",stAge.wMonth-1);
strDays.Format("%d",stAge.wDay-1);
|
|
|
|
|
Have you considered the COleDateTimeSpan class?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hmm. Looking this up in MSDN I have found out that CTime has constructors for accepting SYSTEMTIME and FILETIME objects.
Looks like I'll be rewriting the code with an even better solution!
|
|
|
|
|
I have got some shortcuts in "All Programs"-> "Accessories" -> "Test Menu".
“Test Menu” contains some shortcuts of applications and those are not sorted, can anyone please tell how to sort those shortcuts programmatically.
Manually I can do this by using popup menu “Sort by Name” as shown in screen shot.
http://img142.imageshack.us/my.php?image=shortcutsortingquestionbl8.jpg
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
modified on Monday, February 25, 2008 6:57 AM
|
|
|
|
|
It may well be that there is no way of doing it programmatically. I know many things to do with the start menu are no longer controllable from external programs (ie the pin list) - and that's a good thing. What you want to do might fit in that category.
Is it so bad for the User to do this for themselves - after all they might not want things sorted, if they're used to the layout as it is now.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Have you read through Michael Dunn's Shell Extension articles[^]? This sounds like you simply need to snag on to the contxt menu and select "Sort by Name."
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
In vista os,when i am trying to open a dialog in application b.exe through another application a.exe the dialog is always appearing on the taskbar.It is not getting displayed on the screen unless you press on the minimized dialog on taskbar.How to change this behaviour?This happens only in vista not in XP.
Thanks,
Sheetal
|
|
|
|
|
Do you have code in place that is initially minimizing the window?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No code for minimizing.
This behaviour is only in Vista.
In xp it is not getting minimized.It is displayed on top of all other windows.
|
|
|
|
|
So what does your app's OnInitInstance() method look like?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
[edit]
Problem is solved.
1. The IDE of Visual C++ 2005 does NOT support individual manifest files for different configurations (Win32 and x64) in one single project, even though the Project Properties look like it can. No, it doesn't!
Solution: Use the command-line to run MT.exe.
2. For compatible with WinXP, we should use the sample manifest mentioned HERE[^].
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-com:asm.v2">
<ms_asmv2:security>
[/edit]
I was going to add something in the manifest files for UAC for my project. My project has two configurations: Win32 and x64. So I added two manifest files, "vista32.manifest" and "vista64.manifest, into the project.
Then I went to the project properties:
Configuration Properties | Manifest Tool | Input and Output,
and added "$(InputDir)vista64.manifest" in "Additional Manifest Files" field for Win32 configuration,
and "$(InputDir)vista32.manifest" for x64 configuration.
The content of "vista64.manifest" looks like this:
(because of the domain policy, my IE rejects copy-n-paste on CP. There might be typo below.)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X64"
name="IntelClkRun64"
type=""/>
<description>some description</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
And Win32 version is similar. The only difference is below:
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="IntelClkRun32"
type="Win32"/>
It won't compile happily when file "vista32.manifest" is assigned to Win32 configuration and file "vista64.manifest" to x64 configuration. The error message is as below.
1> .\vista32.manifest : manifest authoring error c1010001: Values of attribute "processorArchitecture"
not euqal in different manifest snippet.
How should I resolve this issue for Win32 and x64 co-existance in one project? And is there any mistake in the manifest content?
Thanks in advance!
Maxwell Chen
modified on Tuesday, February 26, 2008 6:57 AM
|
|
|
|
|
And if just Win32, is my method correct?
Maxwell Chen
|
|
|
|