polyglot-rust-c

Create Rust/C source files that compile with rustc and g++ or gcc.

134|21|Updated Nov 12, 2025
One-click install
npx skills add https://github.com/letta-ai/skills --skill polyglot-rust-c
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: polyglot-rust-c
Source: https://github.com/letta-ai/skills/tree/main/ai/benchmarks/letta/terminal-bench-2/trajectory-feedback/polyglot-rust-c
Command: npx skills add https://github.com/letta-ai/skills --skill polyglot-rust-c

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides creating polyglot source files that compile and run as both Rust and C/C++ programs, leveraging cross-language syntax tricks and preprocessor hacks.

Core Features & Use Cases

  • Dual-language skeleton and compilation workflow
  • Techniques to hide one language inside comments or preprocessor blocks
  • Phase-by-phase incremental development and testing

Quick Start

Create a minimal file that compiles as both Rust and C/C++, then incrementally add features while verifying both compilers succeed.

Frequently Asked Questions about polyglot-rust-c

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write source code that compiles as both Rust and C/C++?

Polyglot source files use shared syntax patterns, comment-driven hiding, and preprocessor blocks to compile correctly with both rustc and g++/gcc. Structure your code so each compiler ignores the other's syntax while executing common logic.

What techniques hide one language inside a polyglot Rust/C file?

Comment-driven hiding leverages multi-line comments (`/* */`) that Rust and C both recognize, preprocessor directives (`#ifdef`, `#endif`) that conditionally exclude code, and shared syntax islands where both languages overlap.

Can I use polyglot programming for CTF challenges and educational exercises?

Yes. Polyglot Rust/C source files work for CTF tasks, security puzzles, and dual-language learning. Verify compilation and runtime correctness with both compilers and cross-validate functional output across environments.

How do I set up and test dual-language compilation incrementally?

Start with a minimal skeleton that compiles in both rustc and g++/gcc, then add features phase-by-phase while running both compilers and checking runtime output. Use a verification checklist to confirm successful cross-compiler validation.

What are the prerequisites for creating polyglot Rust/C source files?

You need Rust compiler (rustc), C/C++ compiler (gcc or g++), and understanding of syntax that both languages share. Knowledge of preprocessor directives and comment styles is essential for hiding language-specific code.

Why would I use polyglot programming instead of separate language files?

Polyglot source unifies dual-language logic in a single file, reducing code duplication and maintenance burden. It's useful for educational demonstrations, CTF obfuscation, and proving cross-language compatibility.