std::vector autocomplete not working inside Xcode 6.6 - c++

I'm just trying to build a very simple program that uses std::vector in Xcode.
Here are my configuration settings -
Apple LLVM 6.1 - Language C++ C++ Language dialect =
GNU++11[-std=gnu++11] C++ Standard Library = libc++ (LLVM C++
standard library with C++11 support)
Code like this below works fine, I can use the std:: library as I need it. However, the ctrl+space autocomplete doesn't seem to work for some things. Like for example, it doesn't give me std::vector as an suggestion
std::vector<double> measurements
Here are my header search paths
-/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
-/usr/local/include
What could I be doing wrong? The code builds and runs fine!

Related

How to visualise STL container contents in debugger using Clion and GCC on an M1 Mac

I have a large C++ project that makes use of C++20 features and I'd like to be able to work on it using CLion on an M1 Mac. Since clang doesn't yet support all of C++20, I have installed g++-12 and configured Clion to use this.
Everything seems to work fine, except when debugging I cannot see a reasonable visualisation of the contents of STL containers.
For a simple Hello World with a vector:
If I switch the C++ compiler back to default (clang) in toolchains, it produces a nice visualisation as expected.
I've tried unchecking/checking the "Enable GNU C++ library renderers" option in Debugger->Data Views->C++, and supplying "stdlib=libstdc++" as mentioned here https://blog.jetbrains.com/clion/2015/02/clion-eap-news-cmake-3-1-stl-renderers-in-debugger-pty-and-more/.
Neither have made a difference.
Any ideas would be much appreciated.

xcode 5.1.1 complaining: ISO C++11 does not allow access declarations

I have a project that builds and runs fine on Xcode 4.6.3.
But it does not on Xcode 5.1.1.
This is the unique error I get, hundred times.
"ISO C++11 does not allow access declarations; use using declarations instead".
Basically it wants me to go from:
typedef Something<MType>::Index Index;
Something<MType>::N;
to
typedef Something<MType>::Index Index;
using Something<MType>::N;
Why is it?
If I "solve it" as Xcode says, the final app behaves randomly.
Is it possible to build this project on Xcode 5.1.1 as if it were 4.6.3? (in other words: changing the project settings, but keeping the code intact)
AFAIS, the C++ flags have the same value for both Xcode versions.
C Language Dialect = GNU99 [-std=gnu99]
C++ Language Dialect = GNU++11 [-std=gnu++11]
C++ standard library = libc++ (LLVM C++ standard library with C++11 support)
It looks like a deliberate change to the compiler:
http://llvm.org/viewvc/llvm-project?view=revision&revision=183882
The standards body says: "Access declarations were deprecated in the 1998 standard and have no benefits over using-declarations. They should be removed in C++0x."
And I can't find anyway of reverting to an older (non-standard compliant) C++11 behaviour. I was half expecting this to work:
clang -std=c++0x
But, it doesn't. You get the same error.
Including using looks like the right fix. I've just done some testing here and it does what it says on the tin.
Probably not what you want to hear, but I think you should look into why the code behaves randomly when you use the using directive.

Does Poco work with LLVM standard C++ library?

C++ is not currently one of my main languages - still learning. . . (so go easy on me). .
I'm setting up Poco on iOS. . . It works when I link against Gnu C++ standard library, but when linking against LLVM standard library I get a bunch of errors - unable to find std::string. . .
Does it work with llvm standard lib?
Does it work with C++11 (interesting questin, but not that important since I'm also interested in targeting Android and using Poco for the Threading).
We have built static libraries that work for both iOS, and also for Android: using the Android platform notes presented here
Minor edits to the code should make poco work using stlport_static. but using gnustl_static works out of the box.
the iOS static library work out of the box in Xcode using: c-dialect:GNU99, c++-dialect GNU++11, C++-library libc++ and the LLVM 4.2 compiler.
GCC_C_LANGUAGE_STANDARD = gnu99
CLANG_CXX_LANGUAGE_STANDARD = gnu++0x
CLANG_CXX_LIBRARY = libc++
(One tiny edit might be needed on version 1.51 of poco for iOS and Android, if stl-library version you have is different from the std:: namespace used in Poco).
Depends which version you use, 1.5.1 release should work (see https://github.com/pocoproject/poco/issues/46 ). I don't think the fix was backported to 1.4.x
Since there were no other answers, answering based on the advice from the comments:
As of Jan, 2013, it will work with C++11 dialect, but it doesn't seem to like the llvm std lib. . Gnu std lib works.

I'm having some trouble with C++11 in Xcode

I'm a Mac OS X Lion user who uses Xcode for C++, and it appears that no updates are available for Xcode. I do not appear to be able to compile C++11-exclusive code, but for whatever reason, I thought Apple had gotten C++11 pretty much implemented. And yes, I do have support for Command Line Tools.
Then again, that might just be me. If so, is there any sort of IDE that supports C++11, or any way to upgrade?
I use Xcode and set the following settings:
C++ language dialect: C++11 or GNU++11
C++ Standart Library: libc++ (LLVM C++ standart library with C++11 support)
Xcode version: 4.3.2
If you're using Xcode 4.3 there are several relevant project settings you need to use C++11 features. The first is to use the clang compiler. Something like
GCC_VERSION = com.apple.compilers.llvm.clang.1_0
in your .xcconfig will set it, or you can use the GUI.
Next, you need to tell LLVM which C++ standard to use:
CLANG_CXX_LANGUAGE_STANDARD = gnu++11
This will make language features like range based for, delegated constructors, etc. available.
Finally, if you want to use C++11 STL features (such as std::unordered_map) you need to use the libc++ STL:
CLANG_CXX_LIBRARY = libc++
On XCode 5 / opencv 2.4.9, I can select:
And it builds without error.
If i set the libc++ without specifying C++ Language Dialect then I get same issue as OP

Xcode support of lambda functions

I have a program coded in VS that I'm trying to port over to Xcode. There are several issues I have ran into including use of lambda functions. Since Xcode uses gcc 4.2 and thus doesn't support C++11, will I not be able to use any lambda functions?
If I want to work on the code from my laptop without rewriting much of the code, will I have to install gcc 4.6 and compile using the terminal?
You have few options:
Re-write your code to the C++ 2003 standard.
Install GCC that supports C++11 features being used in the code and not use Xcode (you may use other IDEs, for example QtCreator or Eclipse CDT).
Wait for Xcode that comes with LLVM C++ compiler that supports C++11 features.