Search code examples
c++xcodeeditorcode-completion

Why does XCode insert square brackets when I try to enter the C++ scope resolution operator, ::?


Given the following in-progress C++ code:

if (true)
    std

, as soon as I enter the first colon (:) of the scope resolution operator (::), XCode oddly inserts some square brackets, and my code looks like this:

if [(true)
    std:]

This is really annoying, and it can't figure out why it's doing it. At the moment it's doing it in some files but not others.


Solution

  • It looks like it's trying to help you with Objective C syntax.

    At a guess, the files where it's trying to do that have an extension indicating that what you're writing is Objective C. The files where it's not doing it are those that have an extension indicating that they contain C++ instead.