Reputation: 7060
Is there any way of using aix/solaris compiler on windows so that we are sure the application would not break on non windows platform?
Different compilers expect the standards of code to be different ,Can this be made sure from one operating system?
I know that compiling on platforms like solaris/AIX would mean that the code would compile on windows compiler most of the times.
But can this process be done from windows , with the additional strictness required for non windows platforms?
Upvotes: 0
Views: 554
Reputation: 153977
Not that I know of. Each compiler has its own idiosyncrasies, and it isn't reasonable to expect any one compiler to try to imitate all of the others. What you should do (although as far as I know, g++ is the only compiler to offer the option) is to specify a fairly early version of the standard (e.g. -std=c++98
), and hope for the best. There will be special cases which it will miss (for a long time, Sun CC has non-conformant libraries, for example), but by not using C++11 features, for example, you should limit the problems.
If possible, the simplest solution might be to impose the same compiler (g++, or maybe clang) everywhere.
And of course, wrap anything that interfaces directly with the system. (My experience is that programs which compile and run under Unix do not work under Windows, because there always seems to be the call to a Posix function in them, which isn't present under Windows, or has different semantics under Windows. And back when I was doing most of this, my basic compiler was Sun CC, with the non-conformant library, which broke with VC++ and just about every other compiler as well.)
Upvotes: 2