بنقرة واحدة
writing-c
Coding style and guidance when writing C code. Use whenever C code is being written, read or updated.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Coding style and guidance when writing C code. Use whenever C code is being written, read or updated.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Guidance for registering RISC OS allocations with the RISC OS Open allocation service. Use when the user wants to register a module name, SWI chunk, error block, *command, filetype, system variable, or any other RISC OS allocation. Also use when the user asks "how do I register X", "I need to allocate X", or wants to send an allocation request to RISC OS Open.
Create, extend, review, and repair RISC OS CI pipelines, especially GitHub Actions and GitLab CI files, optional matching `.robuild.yaml` or `.robuild.yml` files for build-service jobs, 32-bit and 64-bit builds, build-service testing, artifact packaging, and draft releases. Use when Codex needs to work on `.github/workflows/*.yml`, `.gitlab-ci.yml`, `example-ci.yml`, `.robuild.yaml`, `.robuild.yml`, `riscos-project create-ci`, build.riscos.online integration, or RISC OS packaging/testing patterns for AIF, RM, and library-export projects.
Create useful pull requests or merge requests with clear reviewer-focused descriptions. Use when opening a PR or MR, especially when the description should explain the problem, summarise the changes, and record testing in a standard structure.
How to design modules for RISC OS. Use when creating new modules, designing interfaces to modules, porting a library to be used in a new module, or extending the existing interfaces of modules.
Port C projects to RISC OS using `riscos-cport`, RISC OS makefiles, and Norcroft/RISC OS build validation. Use when a repository needs a RISC OS library or command-line port, especially when you need to create a `RISCOS/` tree, generate `Makefile,fe1` files, or repair source for the RISC OS toolchain.
Read and translate RISC OS ObjAsm/ARM assembly into another language, PyModule, tests, or interface documentation. Use when converting `s/*` assembler modules, reconstructing SWI behaviour, validating comments against generated tables/disassembly, or proving binary-compatible data layout and boundary behaviour.
| name | writing-c |
| description | Coding style and guidance when writing C code. Use whenever C code is being written, read or updated. |
| metadata | {"author":"gerph@gerph.org"} |
| license | MIT |
| allowed-tools | Bash(riscos-libsearch:*) |
c, and do not have an extension.h, and do not have an extension.c/file_writer, and its header would be called h/file_writer.#include "file_writer.h".c/filename.c or h/filename.h.Makefile and end with ,fe1.
$AMUFILES.aif32/<name>,ffa (32-bit absolute) or aif64/<name>,ffa (64-bit absolute)rm32/<name>,ffa (32-bit module) or rm64/<name>,ffa (64-bit module),fd1. They do not need line numbers.VersionNum, a C include file which describes values.cmhg directory will exist with a file describing the module definition and entry points.$ROBUILD_PROJECT contains its name.WimpClicks over wimp-clicks for the built application and package name.c/module, and hardware interface would be in c/hardware.In the filesystem:
Wrong:
c/name.ch/name.hCorrect:
c/nameh/nameint32_t, uint32_t and friends as appropriate. int64_t is not available for 32-bit, but is available in the 64-bit compiler.int32_t rather than int, so the layout remains correct in 64-bit builds.Serious error: <command> expected but found '<type>', this probably means that there is a variable declaration in the middle of the function. C89 requires that variable declarations be at the start of the block.enum if you need to enumerate a set of values like state values.#define for values like bit-fields and constant strings.RISC OS is single-threaded. Do not use threading or assume re-entrancy.
stdint.h and stdbool.h if needed.kernel.h and swis.h.stdlib.h for NULL when needed.File prologues:
/*******************************************************************
* File: filename
* Purpose: Description
* Author: AUTHOR
******************************************************************/
Function prologues:
/*******************************************************************
Function: function_name
Description: Description of function
Parameters: var = value
Returns: none
******************************************************************/
static helper with the same name as a shared helper already declared in a header. The 64-bit toolchain will reject this immediately.__riscos64, either provide a real 64-bit implementation or return an explicit unsupported/error result rather than relying on implicit declarations.#ifdef __riscos64 guarded cleanly.When porting code that talks to the graphics or pointer system, separate it into:
This makes it possible to implement and test the orchestration logic before the real plotting or output backend exists. For example, tiled sprite plotting can be implemented as:
That keeps partial implementations honest and avoids hard-coding fake graphics behaviour into otherwise reusable logic.
When part of the implementation drops below the normal graphics interfaces and touches screen memory directly, isolate that path behind dedicated helpers. That makes it easier to keep cursor removal, mode checks, and 32-bit/64-bit differences local to the framebuffer code instead of leaking through the general rendering logic.
When porting BBC BASIC code that uses fixed-offset records and ad hoc blocks:
When tests are skipped because of OS version or environment restrictions, count and report the skipped cases explicitly. Do not silently reduce the apparent coverage of the test run.
{ } block, or wrap the logic in a new { ... } block:void my_function(void)
{
int i = 0;
do_something();
{
int j = 5; // Valid in C89 because it's at the top of this sub-block
do_more(j);
}
}
o.modhead (the CMHG object) or your assembly objects (e.g., o.veneer) are missing from the OBJS variable in your makefile./riscos-built/Export/C/ and /riscos-built/Export/Lib - searched first./riscos-resources/Export/C/ and /riscos-resources/Export/Lib - searched second.riscos-libsearch to find exported headers, libraries, functions and defines:
riscos-libsearch ScreenSave - find a function or define by name.riscos-libsearch Sprite.h - find matching headers and their host filenames.riscos-libsearch --symbols riscos/Sprite.h - list symbols from a header.riscos-libsearch --lib RISC_OSLib - show a library's headers, objects and symbols.riscos-libsearch --lib-list - list known libraries.riscos-libsearch reads the baked system index from /riscos-resources/Export/Lib/libraries.db and, when present, the user-built index from /riscos-built/Export/libraries.db. Built results take priority over system results for the same include path./riscos-built/Export has changed and lookup results look stale, run riscos-libsearch --index to rebuild the user-built index.riscos/NAME.h is held in file riscos/h/NAME):
riscos/CMOS.h - NVRAM valuesriscos/DynArea.h - Dynamic area constantsriscos/EnvNumbers.h - Program environment registration valuesriscos/Events.h - Event numbersriscos/FileTypes.h - RISC OS file type numbersriscos/Heap.h - OS_Heap constantsriscos/Messages.h - Wimp message numbersriscos/ModeVariables.h - OS_ReadModeVariable and OS_ReadVduVariables valuesriscos/ModHand.h - RISC OS module area constantsriscos/NewErrors.h - Error numbers and standard stringsriscos/OSPlatformFeatures.h - Platform informationriscos/OSReadSysInfo.h - OS informationriscos/OSScreenMode.h - Screen mode selection and informationriscos/Oswords.h - OS_Word constantsriscos/Pointer.h - OS_Pointer constantsriscos/Services.h - Service numbers.riscos/Sprite.h - OS_SpriteOp constantsriscos/UpCall.h - OS_UpCall constantsriscos/Vectors.h - Vector numbers