You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Eclipse CDT项目默认C++标准是什么?(CDT 3.8.1+GCC 8.6.0)

Confirming Default C++ Standard in Eclipse CDT 3.8.1 with GCC 8.6.0 Cross-Compiler

Let's get to the bottom of this—great question about verifying your default C++ standard, especially since Eclipse CDT's UI isn't making it obvious here.

First, Understand the Core Behavior

Eclipse CDT doesn't set a default C++ standard on its own; it relies on the GCC cross-compiler's native default unless you manually add a -std= flag in your project's build settings. That said, GCC 8.x normally defaults to C17, so your observation that it's not C11 suggests either your cross-compiler was customized for legacy compatibility, or there's a hidden flag in Eclipse overriding it.

How to Get the Definitive Answer

There are two foolproof ways to confirm:

1. Ask the Compiler Directly

Open a terminal and run this command against your cross-compiler (replace your-cross-g++ with the actual path/name of your GCC cross-compiler's C++ frontend):

your-cross-g++ -dM -E -x c++ /dev/null | grep __cplusplus

The output will be a macro value that maps directly to the C++ standard:

  • 199711L = C++98
  • 200305L = C++03
  • 201103L = C++11
  • 201402L = C++14
  • 201703L = C++17

This is the most reliable check because it bypasses Eclipse entirely and shows you exactly what the compiler uses by default.

2. Check Eclipse's Build Flags

Eclipse might be adding a hidden -std= flag without showing it in the language support UI. To verify:

  • Right-click your project → Properties → C/C++ Build → Settings
  • Go to the Tool Settings tab, expand your cross-compiler's C++ Compiler → Miscellaneous
  • Look at the Other flags field. If you see a -std= entry here, that's the standard being used. If not, Eclipse is using the compiler's native default.

Why -std=c++03 Works (Even If It's Not Listed)

You noticed Eclipse's language support page doesn't mention C++03, but adding the flag doesn't throw an error. That's totally normal:

  • Eclipse CDT 3.8.1's UI only lists newer standards it explicitly supports for syntax highlighting and code analysis (C++11 and later), but it doesn't block valid compiler flags.
  • GCC has supported C++03 since its release, so passing -std=c++03 will always work with GCC 8.6.0.

Is Your C++98 Guess Correct?

It's possible—especially if your cross-compiler was built for embedded systems where legacy compatibility is prioritized. The __cplusplus macro check will give you the exact answer, but if you're seeing behavior that doesn't align with C11 features (like auto type deduction not working), that's a strong hint it's a pre-C11 standard (either C98 or C03).

内容的提问来源于stack exchange,提问作者Rick D.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:32:14