Does Visual C++ runtime imply Windows platform? I mean if I write a program that only directly uses functions specific to VC++ runtime and doesn't directly call Windows API functions can it be recompiled and run on any OS except Windows? I don't mean on Windows system emulator, I mean a ready implementation of VC++ runtime for some other OS.
The Visual C++ runtime contains the standard C++ library and platform specific auxiliary functions. The Windows API is part of the Windows SDK, and is not included in the Visual C++ runtime.
When you compile a C++ program on a different platform you will use that platform's C++ library implementation.
I mean if I write a program that only directly uses functions specific to VC++ runtime and doesn't directly call Windows API functions can it be recompiled and run on any OS except Windows?
As long as you only use standard C++ functions and classes, yes.
I don't mean on Windows system emulator, I mean a ready implementation of VC++ runtime for some other OS.
The runtime itself is only available on Windows, as the implementation is very platform specific. As I have mentioned above, you only get source level compatibility and only if you don't use MS specific functions.
These are two different questions. If you stick to portable parts of C and RTL, you can of course recompile for a different platform - I do that on daily basis. But a VC++-generated executable can only be run on Windows - it's a Windows executable :)
However, don't assume that the whole VC++ runtime library is portable. Some functions are (strlen() for example), some exist but are named differently (strnicmp()), some are simply absent on other platforms.
Once upon a time it was possible (Visual C++ 4.x?) to target Mac (68000 processor) with MFC/Visual C++, but that project has been abandoned for a long time.
Microsoft Mobile/Smart Device is some sort of cross development supported in the latest version of Visual Studio.
The "VC++ Runtime" refers to Microsoft's implementation of the standard C and C++ libraries on top of Windows, so yes, in that sense it does imply the Windows platform. (In fact, it's implemented in terms of the Win32 API since the OS needs to support all of those great things the standard library can do for you).
However, since it's just the implementation of the standard libraries for the C and C++ languages, as long as you're careful to write portable code (don't assume type sizes, don't use platform/compiler specific extensions to the standard, beware of functions with differing names/arguments, etc. etc. etc.), you should be able to recompile it for any platform that has a C/C++ standard library implementation available.
I mean if I write a program that only directly uses functions specific to VC++ runtime and doesn't directly call Windows API functions can it be recompiled and run on any OS except Windows?
If by "functions specific to VC++ runtime" you mean standard library functions, then the answer is yes (but with some caveats)
If you mean non-standard functions that are in the VC runtime but aren't standard, like _snprintf()
, then the answer is generally no (but other implementations might support them so you might be able to get away with it).
The caveats from the 1st answer are that your program might take advantage of implementation specific (or even unspecified or undefined) behavior that might make it not work the same on a different platform, even if your program uses nothing but standard library functions. In most cases these issues won't be a problem, but they are something to take into consideration when writing code that you want to be portable.