Enabling C++11 symbols resolution in Eclipse Juno ADT

╄→гoц情女王★ 提交于 2019-12-04 21:10:47
HRold

If your Eclipse Juno with ADT plugin can compile C++11 code but fails to resolve C++11 symbols, here is the procedure:

  1. Open your .cproject file in a text editor.

  2. Search the following line (where XXXXXXXXX is a random number):

    <tool id="com.android.gcc.compiler.XXXXXXXXX" name="Android GCC Compiler" superClass="com.android.gcc.compiler">
    
  3. Add the following into it:

    <option id="com.android.gcc.compiler.option.preprocessor.def.768340103" superClass="com.android.gcc.compiler.option.preprocessor.def" valueType="definedSymbols">
        <listOptionValue builtIn="true" value="__cplusplus=201103L"/>
        <listOptionValue builtIn="false" value="__cplusplus=201103L"/>
        <listOptionValue builtIn="true" value="__GXX_EXPERIMENTAL_CXX0X__"/>
        <listOptionValue builtIn="false" value="__GXX_EXPERIMENTAL_CXX0X__"/>
    </option>
    

    You should have something like this (where YYYYYYYYYY is also a random number):

    <tool id="com.android.gcc.compiler.XXXXXXXXX" name="Android GCC Compiler" superClass="com.android.gcc.compiler">
        <option id="com.android.gcc.compiler.option.preprocessor.def.768340103" superClass="com.android.gcc.compiler.option.preprocessor.def" valueType="definedSymbols">
            <listOptionValue builtIn="true" value="__cplusplus=201103L"/>
            <listOptionValue builtIn="false" value="__cplusplus=201103L"/>
            <listOptionValue builtIn="true" value="__GXX_EXPERIMENTAL_CXX0X__"/>
            <listOptionValue builtIn="false" value="__GXX_EXPERIMENTAL_CXX0X__"/>
        </option>
        <inputType id="com.android.gcc.inputType.YYYYYYYYYY" superClass="com.android.gcc.inputType"/>
    </tool>
    
  4. Save modifications, restart eclipse and if C++11 symbols are still not resolved rebuild your index (right click on the project → "Index" → "Rebuild").


Because the "Symbols" tab was not visible in the C/C++ options of the project, I was forced to add these lines manually in the .cproject file in order to set the value of __cplusplus to 201103L.

I don't know exactly how .cproject files works so there's probably a better way to do it. I've seen some guys changing the toolset options of the project in order to make the "Symbols" tab visible (here Android NDK build, Method could not be resolved and here Setting up C++11 (std::thread) for NDK with ADT/Eclipse).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!