[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: C++ compilers on Linux supporting 64bit architecture?

On Saturday 1 September 2007 2:27:41 pm Sam Varshavchik wrote:
> Bo Berglund writes:
> > 3) The program is written in C++, would there be big porting issues
> > moving it from Windows to Linux, code-wise?
> That depends upon what libraries your C++ code uses. If it uses
> Windows-specific libraries, any GUI libraries, they are obviously not
> available on Linux.
> If your C++ code uses only the standard C library and only the C++ STL, it
> should compile and run on Linux with minimum fuss, unless, without your
> knowledge or awareness, you are using any Microsoft-specific perversions of
> standard C library calls or C++ STL, in your code.

Even once you have worked through the slight oddities that mean C++ on windows 
isn't quite the same as C++ on linux, you can find cases where at run time 
you don't get the same results. If this is important to you it can be a right 
pain to trace problems. A couple examples found recently in a project I work 
on that supports both windows and linux, 

 float x = pow( 10, -6 ); 
on linux this gives you 1e-6. On windows you get 0 !! 

std::sort( .... ); The STL standard states that for elements that are "equal" 
(whatever that means for the predicate) the final order is not defined. 
Anything which is not defined in the standard you can read as possibly 
platform dependant. IN this case the fix is easily, as std::stable_sort(...) 
is for exactly this case, as in preserve the original order of 'equal' 

These are just two examples, I'm sure there are many other ways in which you 
could find linux and windows don't give identical results. If you care about 
this, you might have a lot of debugging on your ands.

On the plus side, testing your code on two quite different platforms is quite 
enlightening and useful in a testing sense. Both linux and windows can have 
oddities and things which diverge from the standard, and this is a great way 
to find them....


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]