visual c++ and C++ builder - c++

Can C++builder compile any c++ source files.
I don't have a good knowledge in c++. but i have some experience in delphi.
I like to use c++ but confused which one to use
I know that cbuilder has vcl , easy to develop ,easy for delphi developer
But my problem is can it compile any c++ files (vc++ and other source files).
is it compatible with vc++ (excluding MFC and VCL). Can i use any APIs with c++builder

You'll find C++ Builder very comfy coming from Delphi if you don't care about MFC or .NET via C++/CLI etc and just want native C++ then either will work for you. Visual Studio 2010 supports a lot of the new C++0x features which is pretty nice, although they don't have variadic templates yet. I'm not sure how much of C++0x is in C++ Builder as yet but that could be worth looking into as a deciding factor.

It should be able to compile any standards conforming code. If the code uses extensions that another compiler provides, it will more than likely have problems. VC++ has quite a few extensions that are on by default and so someone using that compiler might use them with out realizing what is going on(the same applies to G++ the other major C++ compiler out there.)

In my experience, C++Builder's support for more advanced C++ code is limited. For example, many of Boost's libraries are unsupported in C++Builder, and I've often had to modify other open source libraries to get them to build properly in C++Builder (due to various bugs or limitations in C++Builder's compiler). Simpler C++ code can work without any problems.
So, depending on what C++ libraries / source files / APIs you're wanting to use, getting them to work in C++Builder may be very straightforward, or it may take significant work.

You can download a free version of C++ Builder at www.embarcadero.com. With that, you can test your libraries for compatibility.

Related

Writing C++ code for Linux platform in Visual studio

I am writing code in VS that should be ported later to Linux. I found that sometimes, I may use some functions or code that is available only on Windows and not on Linux.
Is there any way that I can set my Visual Studio to report me these non portable pieces of code?
I prefer to use VS during development and then use the code base and compile it in Linux.
You can treat MinGW as a reference compiler, just to check whether the code you write is portable.
You can also disable MSVC compiler extensions in the compiler options settings in Project Properties (or set /Za flag). That will most likely make at least <windows.h> stop compiling.
Frankly, though, I don't see a problem in simply not using nonportable things. Stick to standard library and libraries that you know are portable and you're good to go. (granted, syntactic extensions are easier to accidentally use, but then again their usages are also typically trivial to put back in proper way).

Is MSVC strictly necessary to compile on windows?

Some open source projects explicitly state that in order to compile on windows, they need a microsoft compiler (often a specific version as well, as latter versions are incompatible or will refuse to compile older code).
Since it seems absurd to me that, since there are foss compilers that can compile for windows, a microsoft compiler would be necessary for any fundamental task, I'm assuming this is because those projects use api calls to libraries (such as msvcrt*.dll) that, for some reason, mingw-gcc, clang and other ports of compilers for windows are unable to compile against.
My understanding of these requirements is shallow, since my experience with compiled code comes primarily from linux and this worries me, since getting a microsoft compiler is non-trivial. the only way to get them is through the express editions of microsoft's visual c++, and even then, the most recent version will completely refuse to install on an old winxp machine like mine and the only version available at the moment is vc++express2010, which requires registrations to turn from trialware into freeware (and even then i'm not clear on if that'll work or what it entails - perhaps OS hooks to "debug" and other intereference?).
1) My question is, do these projects depend on microsoft compilers due to building against these microsoft-only libraries (which apparently foss compilers can't do)?
It would seem absurd if the reason is the build script or preprocessor directives, since those can be relatively easily ported.
2) Also, is it possible that, even if I avoid any msvcrt/.net/etc. calls, i can still find myself needing a microsoft compiler to compile native windows software (assuming no usage of libraries that do perform those calls)?
3) Can I simply use clang and some widget library to make native windows software just as well?
4) Can I modify the source of a project so that it doesn't depend on a microsoft compiler?
(ok that's 4 questions, sorry, this is quite hard for me to express clearly).
1) My question is, do these projects depend on microsoft compilers due
to building against these microsoft-only libraries (which apparently
foss compilers can't do)?
Compiler vendors and GUI framework vendors can supply DLLs that perform similar to the MS DLLs. Some of the MS DLLs are system DLLs and are used by the other compiler and framework vendors.
If you are using compiler or framework specific DLLs, they need to accompany the installation of your programs (projects).
2) Also, is it possible that, even if I avoid any msvcrt/.net/etc.
calls, i can still find myself needing a microsoft compiler to compile
native windows software (assuming no usage of libraries that do
perform those calls)?
No. If you scan through the posts on StackOverflow, there are many people who are using the Windows API directly, I guess what you are calling native windows software. Usually, the code for these API are located in a system API. The compiler translates the function call to a call into these DLLs, loading them as necessary.
3) Can I simply use clang and some widget library to make native
windows software just as well?
No, you can't. That's why they exist.
Again, many people are using frameworks like Qt and xWidgets without the MS compilers. I did that for a while. I switched over to Visual Studio, primarily for the debugger. I didn't like how other IDEs tried to use GDB. Otherwise, I wouldn't use MS because they tend to go by the Microsoft Standard language rather than the ISO.
4) Can I modify the source of a project so that it doesn't depend on a
microsoft compiler?
No, that is why there are freeware and other compilers out there.
Hmmm, one can use Java to create GUIs that don't use the MS compiler, but they use the Windows API.
Try installing Cygwin. When you look at all the libraries you will realize that projects can be created that don't use the MS Compiler. Again, read through the StackOverflow posts and you will find that people are using other compilers, such as Intel, GNU, Clang, Greenhills and others. Some compilers for embedded systems will also compile for Windows OS, so you can write code that works on both platforms.
Looks like you need to search the web for "GNU GUI tutorial C++" and see what pops up. Also, search for "wxWidgets" and "Qt" for other frameworks.

TDateTime data type

I have been using C++ Builder to develop some classes. I have been using the TDateTime data type by including the 'vcl.h'. Is this only unique to C++ Builder?
I ask this because I am now using Microsoft Visual Studio C++ and am getting a 'TDateTime is undefined error'.
How can I use this type in Visual Studio?
Thanks
I would suggest having a look at boost.datetime and, if you have access to C++11 support, the standard C++ time and time duration utilities available in the <chrono> header. One advantage of using either of these is that they are portable, so you are not bound to a given compiler or development environment.
Most of Borland's Visual Component Library is built around it's own compiler-specific extensions and delphi code. I very much doubt you will have an easy time getting it to work under any other compiler.
LUckily there are plenty of alternatives. If you're using Visual C++, then you can use Microsoft's Date/Time libraries:
http://msdn.microsoft.com/en-us/library/6ahxxcsz%28v=vs.100%29.aspx
There are also portable libraries from Boost and QT which should run under any modern C++ compiler
http://www.boost.org/doc/libs/1_51_0/doc/html/date_time.html
http://doc.qt.digia.com/4.5/qdatetime.html

Using Visual C++ with a different C++ compiler?

I like the Visual Studio IDE. I'm used to it and find it is the best IDE I've ever tried. We also find increasing use of C#/.NET here.
However, after the underwhelming announcement regarding C++11 features in VS11 I'm looking into replacing the compiler.
It seems that the Intel compiler fully integrates with VS but that doesn't mean it will compile our Windows code. I don't know how I'd fare with a try of g++ or clang
Can VS actually be productively used with a different C++ compiler to compile Windows code, that is legacy code using all kinds of Win32 / MFC / COM stuff?
Depends on how much use you made of the Microsoft-proprietary extensions. Things like #pragma once tend to be supported by all the major compilers, but the weirder COM things (e.g., #import and anything C++/CLI) probably won't be. No idea if MFC will build under the new compiler, but you'll probably have to link it statically or ship your own DLL; G++ definitely uses a different mangling scheme than MSVC.
I'm not sure how easy it is to replace cl.exe and keep your vcproj files intact (though some compilers actually do it), but there are always Makefile projects.
I have never actually worked with the Intel C++ compiler, but I see no reason why it wouldn't compile the code that VC++ does. Here is official Intel documentation.
I use Visual Studio 2008 with a Makefile project to cross-compile; no reason you couldn't do the same with a different Windows compiler.

Which C++ does Visual Studio 2008 (or later) use?

I find C++ is very controversial language in microsoft world. By default we have ISO C++ and then microsoft has Managed C++ and now C++ CLI.
I just know standard (ISO) C++. I don't know microsoft's version of C++.
I'm confused about interpretation of any c++ code by visual studio 2008 (or later). Thats why I'm using gnu tools for compiling my programs. But I do love Visual Studio.
What settings do I need to make if I only want to use
STRICTLY ISO C++
Managed C++ (its deprecated but I think they still support it for sake of backward compatibility)
C++ CLI (for .NET platform)
I want to build native assemblies using C++ not managed ones. So, is there anything else should I need to do?
Everything is in the build settings:
Common Language Runtime Support (/clr) - add or remove CLR support
Advance Compile as C++ Code (/TP) - to choose if c++ or c..
Language: Disable Language Extention - use this to force ANSI.
When you ask Visual Studio to make a C++ project, it makes a C++ project. C++/CLI is a different language.
VS2008 and earlier have implemented C++03 (or approximated it. Like almost every other compiler, there are bits of the standard that are not followed to the letter. A few features are not implemented (exception specifications, the export keyword or two-phase name lookup are the ones I can think of), and some proprietary extensions are added as well.
GCC, and most big compilers, do the exact same thing, so this isn't a case of Microsoft being "evil" as such. The extensions can be disabled, leaving you with a reasonably standards-compliant compiler.
VC2010 is adding a number of C++0x features (and at least in the beta, I haven't been able to find an option to disable these), so from a strict C++03 compliance point of view, it is going to be less compliant.
Dani's answer already tells you which settings to change to enable/disable different language dialects.