Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Language Standards Support

techy4shri edited this page Nov 25, 2025 · 1 revision

Language Standards Support

CppLab IDE supports multiple C and C++ language standards, allowing developers to write both legacy and modern code.

Supported Standards

C Language Standards

Standard Flag Year Status Description
C99 -std=c99 1999 Stable Legacy support, inline functions, // comments
C11 -std=c11 2011 Stable Multi-threading, _Generic, anonymous structs
C17 -std=c17 2018 Default Bug-fix update to C11, most stable
C18 -std=c18 2018 Stable Alias for C17
C23 -std=c23 2023 Experimental Digit separators, typeof, constexpr

C++ Language Standards

Standard Flag Year Status Description
C++11 -std=c++11 2011 Stable auto, nullptr, lambdas, move semantics
C++14 -std=c++14 2014 Stable Generic lambdas, relaxed constexpr
C++17 -std=c++17 2017 Default Structured bindings, if constexpr, std::optional
C++20 -std=c++20 2020 Stable Concepts, ranges, coroutines, modules
C++23 -std=c++23 2023 Experimental Deducing this, multidimensional subscript

Default Standards

Project Mode

  • C Projects: Default to C17 (most stable modern C)
  • C++ Projects: Default to C++17 (widely supported, stable)

Standalone File Mode

  • .c files: Default to C17
  • .cpp files: Default to C++17

Selection Methods

1. UI Dropdown (Toolbar)

Location: Main window toolbar, next to Toolchain selector

┌──────────────────────────┐
│ Standard: ▼ │
├──────────────────────────┤
│ C++23 │ ← For .cpp files
│ C++20 │
│ C++17 ← Default │
│ C++14 │
│ C++11 │
└──────────────────────────┘
┌──────────────────────────┐
│ Standard: ▼ │
├──────────────────────────┤
│ C23 │ ← For .c files
│ C18 │
│ C17 ← Default │
│ C11 │
│ C99 │
└──────────────────────────┘

Behavior:

  • Dropdown options change based on file extension
  • Selection persists for:
    • Projects: Saved to cpplab_project.json
    • Standalone: Saved in session (not persisted)

2. Project Configuration File

File: <project_root>/cpplab_project.json

{
 "name": "MyProject",
 "language": "cpp",
 "standard": "c++20",
 ...
}

Manual Edit:

// Change from C++17 to C++20
"standard": "c++20"

Reload: Close and reopen project

3. New Project Dialog

When creating a new project:

┌─────────────────────────────────┐
│ Create New Project │
├─────────────────────────────────┤
│ Language: ◉ C++ しろまる C │
│ │
│ Standard: [C++17 ▼] │
│ ┌──────────────┐ │
│ │ C++23 │ │
│ │ C++20 │ │
│ │ C++17 ← │ │
│ │ C++14 │ │
│ │ C++11 │ │
│ └──────────────┘ │
│ │
│ Type: ◉ Console │
│ しろまる Graphics │
└─────────────────────────────────┘

Implementation

Standard Combo Box Setup

File: src/cpplab/app.py

def _update_standard_combo_for_language(self, language: str, 
 current_standard: Optional[str] = None):
 """Update standard combo box based on language."""
 self.standardComboBox.blockSignals(True)
 self.standardComboBox.clear()
 
 if language == "c":
 # C standards (newest first)
 self.standardComboBox.addItem("C23", "c23")
 self.standardComboBox.addItem("C18", "c18")
 self.standardComboBox.addItem("C17", "c17")
 self.standardComboBox.addItem("C11", "c11")
 self.standardComboBox.addItem("C99", "c99")
 default = current_standard or "c17"
 else: # cpp
 # C++ standards (newest first)
 self.standardComboBox.addItem("C++23", "c++23")
 self.standardComboBox.addItem("C++20", "c++20")
 self.standardComboBox.addItem("C++17", "c++17")
 self.standardComboBox.addItem("C++14", "c++14")
 self.standardComboBox.addItem("C++11", "c++11")
 default = current_standard or "c++17"
 
 # Set current selection
 for i in range(self.standardComboBox.count()):
 if self.standardComboBox.itemData(i) == default:
 self.standardComboBox.setCurrentIndex(i)
 break
 
 self.standardComboBox.blockSignals(False)

Language Detection

Based on File Extension:

def detect_language(file_path: Path) -> str:
 """Detect language from file extension."""
 if file_path.suffix in ['.c', '.h']:
 return 'c'
 elif file_path.suffix in ['.cpp', '.cc', '.cxx', '.hpp', '.hxx']:
 return 'cpp'
 else:
 return 'cpp' # Default to C++

Feature Support by Standard

C Standards Feature Matrix

Feature C99 C11 C17/18 C23
// comments [x] [x] [x] [x]
inline functions [x] [x] [x] [x]
Variable-length arrays [x] [x] [x] [x]
_Bool type [x] [x] [x] [x]
<stdint.h> [x] [x] [x] [x]
_Generic [x] [x] [x]
_Static_assert [x] [x] [x]
_Atomic [x] [x] [x]
_Thread_local [x] [x] [x]
Digit separators [x]
typeof [x]
constexpr [x]

C++ Standards Feature Matrix

Feature C++11 C++14 C++17 C++20 C++23
auto [x] [x] [x] [x] [x]
nullptr [x] [x] [x] [x] [x]
Lambdas [x] [x] [x] [x] [x]
Move semantics [x] [x] [x] [x] [x]
<thread> [x] [x] [x] [x] [x]
Generic lambdas [x] [x] [x] [x]
Relaxed constexpr [x] [x] [x] [x]
Structured bindings [x] [x] [x]
if constexpr [x] [x] [x]
std::optional [x] [x] [x]
Concepts [x] [x]
Ranges [x] [x]
Coroutines [x] [x]
Deducing this [x]
Multidim subscript [x]

Example Code

C17 Example

// test_c17.c
#include <stdio.h>
#include <stdint.h>
int main(void) {
 // C11 _Generic macro
 #define TYPE_NAME(x) _Generic((x), \
 int: "int", \
 float: "float", \
 default: "unknown")
 
 int x = 42;
 printf("Type: %s\n", TYPE_NAME(x));
 
 return 0;
}

Build:

gcc test_c17.c -std=c17 -o test.exe

C23 Example (Experimental)

// test_c23.c
#include <stdio.h>
int main(void) {
 // Digit separators (C23)
 int million = 1'000'000;
 
 // typeof (C23)
 typeof(million) another = million;
 
 printf("Million: %d\n", million);
 printf("Another: %d\n", another);
 
 return 0;
}

Build:

gcc test_c23.c -std=c23 -o test.exe

Note: May not work with older GCC versions

C++17 Example

// test_cpp17.cpp
#include <iostream>
#include <tuple>
#include <optional>
auto divide(int a, int b) -> std::optional<int> {
 if (b == 0) return std::nullopt;
 return a / b;
}
int main() {
 // Structured bindings (C++17)
 auto [x, y, z] = std::tuple{1, 2, 3};
 
 // if constexpr (C++17)
 if constexpr (sizeof(int) == 4) {
 std::cout << "32-bit ints\n";
 }
 
 // std::optional (C++17)
 if (auto result = divide(10, 2)) {
 std::cout << "Result: " << *result << "\n";
 }
 
 return 0;
}

Build:

g++ test_cpp17.cpp -std=c++17 -o test.exe

C++20 Example

// test_cpp20.cpp
#include <iostream>
#include <concepts>
#include <ranges>
#include <vector>
// Concepts (C++20)
template<std::integral T>
auto square(T value) {
 return value * value;
}
int main() {
 std::vector<int> nums = {1, 2, 3, 4, 5};
 
 // Ranges (C++20)
 auto even = nums | std::views::filter([](int n) { return n % 2 == 0; });
 
 for (int n : even) {
 std::cout << n << " ";
 }
 
 std::cout << "\nSquare of 5: " << square(5) << "\n";
 
 return 0;
}

Build:

g++ test_cpp20.cpp -std=c++20 -o test.exe

C++23 Example (Experimental)

// test_cpp23.cpp
#include <iostream>
struct Matrix {
 int data[3][3];
 
 // Deducing this (C++23)
 auto operator[](this auto&& self, int i, int j) {
 return self.data[i][j];
 }
};
int main() {
 Matrix m = {{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}};
 
 // Multidimensional subscript (C++23)
 std::cout << "m[1][1] = " << m[1, 1] << "\n";
 
 return 0;
}

Build:

g++ test_cpp23.cpp -std=c++23 -o test.exe

Note: Requires GCC 12+ or similar

Compiler Support

MinGW GCC Version Requirements

Standard Minimum GCC Bundled GCC Status
C99 3.0+ 8.1.0 [x] Full
C11 4.7+ 8.1.0 [x] Full
C17/C18 5.0+ 8.1.0 [x] Full
C23 13.0+ 8.1.0 ⚠️ Partial
C++11 4.8+ 8.1.0 [x] Full
C++14 5.0+ 8.1.0 [x] Full
C++17 7.0+ 8.1.0 [x] Full
C++20 10.0+ 8.1.0 ⚠️ Partial
C++23 12.0+ 8.1.0 ❌ Minimal

What Works Out of the Box

Fully Supported (Bundled GCC 8.1.0):

  • C99, C11, C17/C18
  • C++11, C++14, C++17

Partially Supported:

  • ⚠️ C++20: Most features work, some experimental
  • ⚠️ C23: Basic features, advanced features missing

Limited Support:

  • ❌ C++23: Very limited, many features unavailable

Recommendations

For Maximum Compatibility:

  • Use C17 for C projects
  • Use C++17 for C++ projects

For Modern Features:

  • Use C++20 (test thoroughly)
  • Avoid C23 and C++23 unless you know the bundled GCC supports specific features

Troubleshooting

"error: #error This file requires compiler and library support"

Cause: Using features not available in bundled GCC

Solution: Downgrade to C++17 or C17

"warning: 'xyz' is a C++20 extension"

Cause: Using C++20 feature but standard not set

Solution: Set standard to C++20 in dropdown

"unrecognized command line option '-std=c++23'"

Cause: Bundled GCC too old for C++23

Solution: Use C++20 or C++17 instead


Next: Project vs Standalone Mode
Previous: Compiler & Toolchain Configuration

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /