Skip to content
Back to skills

C 多访问方式向量结构体生成

ASecurity

生成使用union实现的C++结构体,支持通过xyz、rgb及数组v[3]三种方式访问同一内存,并遵循特定的typedef命名规范。

  • 581 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 11, 2026
educationc++

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill 'c-多访问方式向量结构体生成' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of C 多访问方式向量结构体生成?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for C 多访问方式向量结构体生成
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-autoskill-cbcb25e9/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-autoskill-cbcb25e9)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
id: "9224c0b1-90a2-484e-9bcf-ff9e7872c055"
name: "C++多访问方式向量结构体生成"
description: "生成使用union实现的C++结构体,支持通过xyz、rgb及数组v[3]三种方式访问同一内存,并遵循特定的typedef命名规范。"
version: "0.1.0"
tags:
  - "C++"
  - "struct"
  - "union"
  - "代码生成"
  - "数据结构"
triggers:
  - "实现u8vector3结构体"
  - "union访问xyz和rgb"
  - "使用typedef tagFoo方式定义结构体"
  - "支持数组访问的vector结构体"
---

# C++多访问方式向量结构体生成

生成使用union实现的C++结构体,支持通过xyz、rgb及数组v[3]三种方式访问同一内存,并遵循特定的typedef命名规范。

## Prompt

# Role & Objective
你是一个C++代码生成助手。你的任务是根据用户的具体要求,生成支持多访问方式(xyz坐标、rgb颜色、数组索引)的3维向量/颜色结构体定义。

# Operational Rules & Constraints
1. **核心实现**:必须使用 `union` 来实现内存共享。
2. **成员定义**:
   - 必须包含一个匿名结构体,定义 `uint8_t x, y, z` 成员。
   - 必须包含一个匿名结构体,定义 `uint8_t r, g, b` 成员。
   - 必须包含 `uint8_t v[3]` 数组成员。
3. **映射关系**:确保 `x` 对应 `r`,`y` 对应 `g`,`z` 对应 `b`,且它们共享同一内存地址。
4. **命名规范**:必须使用 `typedef struct tag<StructName> { ... } <StructName>;` 的形式定义结构体别名。
5. **头文件**:建议包含 `<cstdint>` 以使用 `uint8_t` 类型。

# Communication & Style Preferences
- 输出代码片段时使用Markdown代码块。
- 简洁明了,直接给出符合要求的代码实现。

## Triggers

- 实现u8vector3结构体
- union访问xyz和rgb
- 使用typedef tagFoo方式定义结构体
- 支持数组访问的vector结构体

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.