|
From: Jonathan M. <me...@un...> - 2007-11-12 08:25:12
|
Hi Guys,
I have submitted a first patch to the tracker (Request ID 1830252).
I'm not sure how you will apply the patch under Windows, but the
normal UNIX patch command is:
patch -p0 < patch
This should be run when the patch file is in the root directory. You
can do a dry-run using:
patch --dry-run -p0 < patch
(Also note, it's safest NOT to do this on a working copy that has
local changes. The safest way is to check out a fresh working copy,
apply the patch, review it, and then commit. You can then merge those
committed changes into your own working copy with an svn up. Please
disregard if you're experienced with patching.)
Can you please check that this patch doesn't break anything for the
Windows build, and then commit it? I will start working on the
Windows-specific filesystem stuff in the JTMVCModel directory next.
This patch addresses the following three problems in the JTMVCModel
directory:
1. Use of "" vs <> in #include directives. For project-specific
headers, the use of double-quotation marks "" rather than angled
brackets <> is more typical. The use of angled brackets for project-
specific headers causes problems for g++.
2. Passing temporary objects by non-const reference. Consider below:
The following C++ program is illegal (according to the actual
standard). The main() function attempts to pass a temporary
std::string object by non-const reference.
=== START CODE ===
#include <iostream>
void printString(std::string &myString) {
std::cout << myString << std::endl;
}
std::string makeString() {
return std::string("Hello World!");
}
int main (int argc, char * const argv[]) {
printString(makeString());
}
=== END CODE ===
The program can be made legal either by explicitly instantiating the
std::string object (making it appear on the stack) or by using a const-
reference. The use of a const reference is illustrated below:
=== START CODE ===
#include <iostream>
void printString(const std::string &myString) {
std::cout << myString << std::endl;
}
std::string makeString() {
return std::string("Hello World!");
}
int main (int argc, char * const argv[]) {
printString(makeString());
// OR, put the string on the stack:
// std::string s = makeString();
// printString(s);
}
=== END CODE ===
I have changed the passing of JTHint in CObservableObserver::Notify()
to const. If this will not work (i.e. if JTHint is actually
modified), then the code can be fixed by following this pattern for
JTHint passing:
Change:
Notify( HintGen(JT_Activity_ALL), this, caller);
To:
JTHint hint = HintGen(JT_Activity_ALL);
Notify(hint, this, caller);
(Or something similar that actually places a JTHint on the stack.)
C++ is a complicated language, and Microsoft do NOT make things easier
by allowing non-standard behavior! :-(
3. The "typename" keyword is required in a couple of places. I don't
fully understand this one myself, but the g++ errors indicated the fix.
Jonathan Merritt.
|