Does c++ work in same fashion on both windows and linux platform?
 If no,what are the differences.

In one sense this question is meaningless. C++ is a computer language and it exists as a set of requirements and the like that define it. The current definition is contained in the ISO/ANSI C++ standard - incorporating TC1 (TC means Technical Corrigenda - i.e. technical corrections). As such it is totally independent of any actual implementation - such as a C++ compiler.

So next let us move on to actual implementations - that is to C++ compilers and libraries. There are many C++ compilers, written by many people and organisations. Some are free, many cost money to buy the required licenses. Some run on only one or a related set of platforms (such as MS Windows 9x, ME, NT, 2000, XP, CE etc..), others run on many platforms (Windows, Linux, Mac OS X, Symbian, UN*X etc...). Many compilers have history - they exist in several versions. Each compiler's support for standard C++ varies. Some are better than others. Older compilers tend to support less of standard C++ than newer compilers or compiler versions. Some have non-standard features or extensions. Compilers are software - so they contain bugs.

The C++ standard also specifies the standard C++ library and this is another area where support may vary - there are several implementations and many compilers supply one (or sometimes two) variation(s). Sometimes the compiler creators write their own standard library implementation. Often they supply or modify an existing version. It is possible to switch to another standard C++ implementation for some compilers - which may be free (see for example STLPort http://www.stlport.org/) or may cost extra (see for example Dinkumware http://www.dinkumware.com/). In fact you could theoretically write your own implementation.

Generally compilers work in similar fashions. They are all command line tools - even though many wrap this up in a nice GUI application often called an IDE or Integrated Development Environment - which supports managing projects, editing code, building projects, and executing and debugging them all in one application.

Compilers all tend to either directly create object code files or create a second language file - usually C or assembler - that is then compiled or assembled to produce the object code files. After this all the object code files are linked together with each other and any library code by a tool called a linker or link loader to produce an executable.

Where they differ is in the names of the tools and the command line options and usage.

Other differences are related to additional tools, libraries and frameworks supplied with the product - Microsoft for example supply many additional libraries and frameworks - such as ATL and MFC to support Windows programming and also supply the Visual Studio IDE. In addition their compiler has many additional Microsoft and Windows only features to support things like COM programming and .NET managed code. Others such as the Comeau compiler supply the compiler, runtime support code and a standard library and nothing else. They do have a very C++ standard-compliant compiler however...

Now let's get down to cases. On Linux you will probably have some version of the GNU development tools - including GNU C++ - installed. The current 3.x.x versions I understand are quite good C++ implementations, getting better as they progress and they include their own implementation of the C++ standard library. The GNU tools support many varied platforms including Linux, various flavours of UN*X and MS Windows. You can get other compilers for Linux including ones from Borland, Comeau, Intel, and IBM.

Windows does not usually have a compiler installed. You have to obtain one. Most professional organisations use Microsoft's Visual C++ - currently part of the Visual Studio .NET 2003 product. However, there are many other MS Windows targeted compilers, including ones from GNU, Borland, Comeau, Intel and Metrowerks - with varying degrees of additional tools etc...

If you require further specific details then ask another question stating the implementations and version concerned.


All Answers

Answers by Expert:

Ask Experts


Ralph McArdell


I am a software developer with more than 15 years C++ experience and over 25 years experience developing a wide variety of applications for Windows NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C (although I do not write just-C much if at all these days so maybe ask in the C section about purely C matters), software development and many platform specific and system development problems.


My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines. Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is). When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD. My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets including system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes. I have an interest in the development of the C++ core language and libraries and try to keep up with at least some of the papers on the ISO C++ Standard Committee site at http://www.open-std.org/jtc1/sc22/wg21/.


©2017 About.com. All rights reserved.