Alo Sarv
lead developer

Donate via
MoneyBookers

Latest Builds

version 0.3
tar.gz tar.bz2
Boost 1.33.1 Headers
MLDonkey Downloads Import Module Development
Payment completed
Development in progress.
Developer's Diary
irc.hydranode.com/#hydranode

Thursday, January 13, 2005

Some updates

Well, got my systems up and running again, so got some development done too. Nothing big and fancy yet tho - added minimal module example to aid future module writers, and enabled -pedantic compile flag, which enforces strict ISO C++ standard compliance from all code. Interesting thing about the latter is that it also detects (and gives errors) on extronous semicolons (;) in places where they shouldn't be (e.g. after function definitions). Generally you don't put semicolons there, e.g.

void myfunc() {
...
};

However, since MSVC parser couldn't handle function-level try .. catch blocks properly and gave parse errors in some cases such as this:

void myfunc() try {
...
} catch (myerr&) {
...
} catch (...) {
..
}

I had to add ; to the last line to keep the parser happy. However, ISO C++ requires no ; there. Ohwell, guess I'll have to implement MSVC_ONLY() macro to compile code only on MSVC in such cases (writing #ifdefs at all such places is tiresome).

On other news, as you might notice, there's google ads on the right side of this blog. While there aren't many visitors right now on the blog, it's still worth a try. Since this is a development blog, adsense will most likely pick up software development-related ads, which should be rather interesting (personally I already found one interesting piece of software through that ad - some MSVC extension called IncrediBuild, that seems interesting and worth a trial run). The money coming from clicks on those ads will be used for additional hardware for better/faster development.

Madcat, ZzZz




Comments:
"function-level try"? wtf is that? Never heard of that? Is that some advanced C++ subject?
Why not just do:

void myfunc()
{
try {
...
} catch (myerr&) {
...
} catch (...) {
..
}
}
 
Reason is simple - indention level. Compare these two identical examples (using dots for spaces cos /pre/ is not allowed in comments):

void myfunc() try {
........if (true) try {
................doSomething();
........} catch (std::exception&) {
................handleError();
........}
} catch (...) {
........handleAllErrors();
}

void myFunc() {
........try {
................if (true) {
........................try {
................................doSomething();
........................} catch (std::exception&) {
................................handleError();
........................}
................}
........} catch (...) {
................handleAllErrors();
........}
}

Which version looks more readable? And this is still a small example.

I wouldn't go as far as to consider it as "advanced" feature, but I do know not many compilers support this syntax - gcc 2.95+ and MSVC 7.0+ support it, but MSVC6, Borland compilers and CodeWarrior do not...

Madcat.
 
Well, would you use compiler-specific macros just to avoid some more indention? More importantly, it's important to write portable code (which compilers other than msvc++ and GCC can compile).
 
These are not compiler-specific macros, this is standard ISO C++ - just not all compilers have caught up to the standard yet. Borland compilers support roughly 60-70% of C++ standard, MSVC supported roughly the same up until 7.0, when they improved the compiler and raised it to one of today's most standard-compliant C++ compilers - with estimated 98% support, while gcc >= 3.2 (minimum required for hydranode) supports roughly 96% of standard ISO C++ features. (Disclaimer: these are rough estimates from somewhere I read, don't take these numbers for anything).

As for portability, I considered it, and realized there's very little benefit from supporting Borland compilers, since MSVC does the job better for win32 anyway, and the only platform we lose by using some more advanced C++ features like the above is Mac OS 9, where only available compiler (to my knowledge) is Metroworks Codewarrior, however a mac running Mac OS 9 wouldn't be much useful for running hydranode anyway, so no loss. GCC has been ported to majority of *NIX's, so no platforms are lost there either.

Madcat.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?