I just started to get my hands dirty with C/C++, and I am still getting my head around the different concepts (I've written mostly Java previously). I'd really like to know which C/C++ compiler is used and also which standard library is included. Also, I'd like to know where I can find the API documentation of the respective standard library (like the Java SE API docs).
For C++:
Xcode 4.6.2 uses the Clang C++ compiler frontend with LLVM as backend which is conform to the C++11 standart and uses libc++ as the standart library.
Here you can finde a apple presentation about libc++.
I'm not an XCode user, but it seems to be Apple's LLVM Compiler (by default) according to Apple's website: https://developer.apple.com/technologies/tools/. But, I guess, like any other IDE XCode does support other compilers like GCC. Also depends on your XCode version it seems: http://useyourloaf.com/blog/2011/03/21/compiler-options-in-xcode-gcc-or-llvm.html
Here's a question in SO that asks about the default compiler and the answer seems to have the code to find just that: In Xcode 4.5, what is "Compiler Default" for "C++ Standard Library" and "C++ Language Dialect"?
According to this post 4.6 uses clang instead of GCC for C++: http://cplusplusmusings.wordpress.com/2013/02/26/c-and-xcode-4-6/
P.S.: Googling does help ;)
I just noticed the second half of the question was never really answered:
... I'd like to know where I can find the API documentation of the
respective standard library ...
A simple Google search will reveal a wealth of information about this. Do note, however, that the "C++ Standard Library" is not the same thing as the "C Standard Library," so be careful of that when searching and reading. C++ has its roots in C, but the two have diverged to become separate languages that share a lot of commonality -- and a lot of hidden differences.
The canonical reference work regarding this is titled, appropriately enough, "The C++ Standard Library" by Nicolai M. Josuttis, published by Addison-Wesley. Many C++ programmers keep this on their bookshelves as a reference.
There is a good online reference for the library at https://cppreference.com/.
If you are interested in specifics of the LLVM implementation used by Apple's Xcode, see https://libcxx.llvm.org/ .
For a comprehensive list of the most highly recommended books and references for C++, Stack Overflow already has a very good FAQ regarding this: The Definitive C++ Book Guide and List.
Related
For a school assignment, I am required to use C++ version 03. I have a Mac, and I was told to use Xcode by my instructor.
After a bit of research, I found the place on where to change the version of C++ that is being used. As shown in the image, the version C++03 is not available. I tried typing "C++03 [-std=c++03]" in the "Other..." option, but my build failed.
I tried searching around on here and online, but I couldn't find anything that provided a solution.
Can someone please give me some guidance on what to do here? I am entirely new to C++, and I simply just want some help in being able to compile my code.
Thanks.
In Xcode on the Macintosh, to use C++03 (which should be nearly the same or identical with C++98), you can select the C++ Language Dialect > Other... > and type in c++03 (lowercase) in the field.
C++03 was more of a "big fix" to C++98, (q.v. this answer). It resolved some ambiguities in the language specification. Rather than being a significant new C++ standard.
You'll note that there are options like C++98 and GNU++98. The GNU++XX options enable several GNU extensions to the language, which if utilized means the code will not be strictly standard C++ compliant.
C++11 was a major change to the language. C++11 and later are sometimes referred to as "modern C++".
I'm a novice programmer who just migrated from Python (on IDLE) to C++ and I'm finding it uncomfortable to know only a few "essential" methods of STL data structures. Is there something like the Python help() function in C++, or some other way to access digestible and concise documentation as regards the Standard Library?
Edit: To be clear, I am looking for a way to access documentation from my computer, preferably from within the IDE/compiler (I currently use and prefer g++ on Cygwin in Windows 7. I also have Code::Blocks, however). Please don't recommend books or mark this question as a duplicate of The Definitive C++ Book Guide and List.
This is the documentation I like the most : http://en.cppreference.com/w/
With a keyword for fast searching in Firefox, it is very efficient
In general Cplusplus.com helps very much.
Maybe the GNU C++
Library will also help.
You could also read the official C++
book by Bjarne Stroustrup.
http://cppreference.com
http://www.cplusplus.com
If you're on Mac OS, you can use the nice Dash which can integrate with editors or be used on its own. It supports the cppreference.com docs (instant offline indexed documentation).
If you're on Windows (Visual Studio) MSDN also provides STL docs.
As I'm on Linux I just use http://cppreference.com, but I'd like to have a good alternative (not Zeal) to Dash.
Bjarne Stroustrup gave a keynote presentation today for the Going Native 2012 conference. In his presentation, he discussed the issue of enforcing correct units. His elegant (IMHO) solution to this involved using an operator I have never heard of before: operator"". Using this operator, he was able to write C++ code that looked like this:
ratio = 100m / 1s;
Where operator""m(...) and operator""s(...) were defined.
Does anyone know of any documentation regarding how to actually use this operator (or even if any modern C++ compilers support it)? I tried searching online, but had no luck. Any help would be greatly appreciated.
The syntax you'd be looking for is "user-defined literals" which is a feature of C++11.
g++ versions 4.7 and better support this feature.
Here is some documentation describing the use of that operator overload:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf
Also see the excellent link Xeo provides in the comments to your question.
Currently the best documentation is probably in the standard itself. You can get the latest version from the commitee's site. According to gcc's site it will be in the next revision of gcc (gcc-4.7). You should be able to test it when building gcc from the SVN repository.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Where do I find the current C or C++ standard documents?
I have several C books, and one of them, C by Discovery, explains the language very well. But so far I don't seem to have been able to find the full C/C++ language and library standards and lists of functions, types, etc., in whole detail.
Where is exactly a full standard for C99 and also the older, supposedly more commonly used and accepted, C language standards, the C++ language standards, and their libraries?
Is there some of them I must pay for, or should I just follow what Wikipedia and documentation like that of GCC cite?
Where else should I go to download or get them fully?
The Wikipedia article C99 has a link at the bottom to a draft of the C99 language specification. It is a draft because the final published version you have to pay for. But the draft is basically accurate, so it's a good reference. This is an extremely long specification of the entire language including the library, but possibly not what you are after. To just see the standard library, simply consult the man pages. Consult the Wikipedia article C standard library for a list and summary of the various functions.
For C++, the same deal. The Wikipedia article C++ has links to various drafts of the complete specification, notably the most recent draft of C++ from 2010 (the old C++, before C++0x comes into effect). The Wikipedia article C++0x has similar links to drafts of the soon-to-be-named C++ 2011 standard. But if you are just looking for a reference on the standard library, you can't go past cplusplus.com's reference section, which includes full documentation for the C library (in C++ mode), the IO library, and the STL (containers and other misc utilities). That's what I use as a day-to-day library reference.
The best online copy of C99 I've found is here:
http://busybox.net/~landley/c99-draft.html
If you want the actual standard, I don't think you can just download it. I believe you have to buy a copy from the American National Standards Institute. The GCC documents don't provide all the detail you need for the base language that GCC extended.
I am new (in a way) to C++ programming. I would like to start doing development in Linux using C and/or C++ as programming languages. I have done some development for a while in Java.
Unfortunately I am not sure where to start. Can you point me to some good resources, and also give me an outline as to what would be the primary difference between C and C++ in Windows and Linux?
Any special steps I need to do to get started? Also any good IDEs. I plan to use Eclipse currently. I am using Kubuntu (version 9.x).
IDEs:
QtCreator: http://qt.nokia.com/products/appdev/developer-tools/developer-tools
Kdevelop: http://www.kdevelop.org/
Books:
Thinking in C++ / Bruce Eckel http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
Brose standard libraries:
http://www.cplusplus.com/reference/iostream/
It is good that you are using a Linux platform as it will help you to program as per the C and C++ standards.
I would recommend
vi/vim --> text editor
gcc --> C compiler
g++ --> C++ compiler
gdb --> Command line debugger
ddd --> GUI debugger
I use the above mentioned tools. If you are hell-bent on IDEs, you can use the ones mentioned by Chen Levy
If you have done development in Java, then you can start with any tutorial on the internet. There are literally hundreds of them!
I don't expect it to be hard since you have a Java background.
Here is a nice tutorial on CPlusPlus.com.
Also, check out this question on StackOverflow: The definitive C book guide and list.
IDE
Eclipse is very good as a starting point.
The new CDT provides a completely set up environment.
Just be sure to install gcc and gdb before
trying out anything.
And don't use the eclipse in the ubuntu repos, download a
current release.
Difference Windows/Linux:
The language standard is completely the same in both worlds. (Compiler implementations vary in fullfillment of the standard, but you shouldn't notice anything in the beginning.)
If you stick to cross-platform tools, compiler(gcc/mingw), ide and debugger it can stay this way. (I imply that the obvious differences, like .so s and .dlls and stuff are known)
If you move over to other compilers and library implementations (MSVisualC++ for instance) it can get interesting in the advanced stages, but it shouldn't be too difficult to bridge the gaps.
Good/essential libs to know:
the stl, boost, and maybe for productivity and ease in the beginning: qt.
These are as platform independent and generally useful as possible. Know them, and they are usable through your complete c++ lifetime.
(Don't make the mistake to want to learn it all in one go, just go step by step.
Don't try template programming in the beginning, it is mind-boggling ;) but using
templates is fun)
IDE / Editor I think with Eclipse you can quite good start with. I perfer emacs and use of the command line tools of gcc. Why? I think you learn more of the basics how they work.
Good libs: STL, QT, boost with these tree you have the ability to create/develop most of the parts you like or you need.
In my opinion very important is that you stuck (in the beginning) to the libray you selected. And also to the IDE/editor.
Starting point: As earlier mentioned Thinking in C++, Second edition (Volume 1 &2) by Bruce Eckel. He trys to explain the difference between C and C++. In volume 1 he explains the basics of C++ and in volume 2 he introduces some parts of the STL.
Another usefull ressource for me was C++ FAQ lite Here you can find a lot of usefull tipps.
If you will ever want some library good places to start are sourceforge.net and freshmeat.net