writing-cplusplus
Skill4 starsChanged 7 months agoMITView on GitHub
Guidance for writing, reading, updating, building, and testing C++ code for the 64-bit RISC OS build environment. Use whenever Codex works on RISC OS C++ command projects, `cc/` sources, C++ headers in `h/`, `riscos64-c++`, `riscos-project --type c++command`, `${C++LIB}`, or C++ interop with C and RISC OS APIs.
We split this skill into the rules it gives an agent
25 rules. About 0 are common, 15 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Use this skill for C++ in the RISC OS cross-compilation environment.
- Distinctive: line 26
Prefer simple, explicit C++ using ordinary functions, classes, constructors, destructors, references, and C-compatible interfaces where …
- Distinctive: line 31
Use the RISC OS source filename conventions:
- Very specific: line 40
Do not create source files such as cc/main.cpp or headers such as h/countlib.h unless the existing project already uses that convention.
- Distinctive: line 43
Create a new C++ command skeleton with:
- Very specific: line 59
Run the resulting absolute with riscos-build-run --64:
- Very specific: line 77
When using the RISC OS makefile system, put the C++ runtime in LIBS:
- Distinctive: line 96
Put braces at the start of lines when that matches nearby RISC OS C/C++ code.
- Distinctive: line 98
Do not leave trailing spaces.
- Distinctive: line 99
Keep main small and move reusable logic into separate functions or classes.
- Distinctive: line 100
Avoid magic numbers and strings.
- Very specific: line 101
Use static for file-local helper functions.
- Very specific: line 102
Use const for values and references that should not be changed.
- Very specific: line 103
Use RAII for simple ownership, but avoid constructors that need to report failure by throwing.
- Distinctive: line 106
Avoid threads and re-entrancy assumptions.
- Distinctive: line 108
Do not add broad abstractions just because C++ makes them possible.
- Distinctive: line 123
Use fixed-width types at RISC OS and C ABI boundaries:
- Very specific: line 131
Use uintptr_t when converting pointers to integers.
- Very specific: line 137
Use extern "C" for functions compiled as C or exported to C:
- Distinctive: line 157
Do not expose C++ classes, references, overloaded functions, exceptions, or standard library types through C-callable interfaces.
- Distinctive: line 169
Use the project's existing file prologue style for new C++ source files:
- Distinctive: line 179
Do not use the bordered C function prologue format from the C skill for every C++ member function unless the local C++ project already does …
- Very specific: line 184
If a build tries to produce or run 32-bit output, check that BUILD64=1 and riscos-build-run --64 are both present.
- Very specific: line 187
If linking fails with missing C++ runtime symbols, check that ${C++LIB} is in LIBS for makefile builds, or that direct links include …
- Distinctive: line 191
If code fails around exceptions, RTTI, templates, or modules, remove or isolate that feature before chasing unrelated build issues.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Guidance for writing C++ code for RISC OS.
Scope
Use this skill for C++ in the RISC OS cross-compilation environment. C++ is currently supported only for 64-bit RISC OS builds.
Current caveats:
- Exceptions are not supported. Do not use
throw,catch, or code paths that depend on exception unwinding. - RTTI does not work. Do not use
typeidordynamic_cast. - Templates are not tested. Avoid template-heavy designs unless the user has explicitly accepted the risk.
- C++ modules are not tested.
Prefer simple, explicit C++ using ordinary functions, classes, constructors, destructors, references, and C-compatible interfaces where practical.
Project Structure
Use the RISC OS source filename conventions:
- C++ sources live in
cc/and have no host extension, for examplecc/main. - C and C++ headers live in
h/and have no host extension, for exampleh/countlib. - Include headers using their C/C++ names, for example
#include "countlib.h". - Makefiles are named
Makefile,fe1. - The version include is usually
VersionNum.
Do not create source files such as cc/main.cpp or headers such as
h/countlib.h unless the existing project already uses that convention.
Create a new C++ command skeleton with:
riscos-project create --type c++command --name <Name> --skeletonThe skeleton should build before it is extended.
Build And Test
Build C++ command projects for 64-bit RISC OS:
riscos-amu BUILD64=1Run the resulting absolute with riscos-build-run --64:
riscos-build-run --64 aif64/<Name>,ff8 --command <Name>riscos-build-run creates a temporary RISC OS filing system and copies listed
files into its root. If the host file is aif64/Testing,ff8, run it as
Testing, not aif64.Testing.
For direct compiler use:
riscos64-c++ -c -o o.name cc.name
riscos64-link o.name -lsupc++ C:c++64.o.libc++-64 -o name,ff8
riscos-build-run --64 name,ff8 --command nameWhen using the RISC OS makefile system, put the C++ runtime in LIBS:
LIBS = ${CLIB} ${C++LIB}List objects using o. names and let the build system vary them for 64-bit
builds:
OBJS = o.main \
o.workerC++ Style
Match the surrounding project style first. For new C++ code:
- Use 4-space indentation.
- Put braces at the start of lines when that matches nearby RISC OS C/C++ code; otherwise follow the local C++ style already present.
- Do not leave trailing spaces.
- Keep
mainsmall and move reusable logic into separate functions or classes. - Avoid magic numbers and strings; use named constants.
- Use
staticfor file-local helper functions. - Use
constfor values and references that should not be changed. - Use RAII for simple ownership, but avoid constructors that need to report
failure by throwing. Prefer explicit
init,open, orcreatemethods for operations that can fail. - Avoid threads and re-entrancy assumptions. RISC OS is single-threaded.
Do not add broad abstractions just because C++ makes them possible. RISC OS is memory constrained; keep interfaces small and predictable.
Includes And Types
Common includes:
#include <stdint.h>
#include <stdlib.h>
#include <iostream>
#include "kernel.h"
#include "swis.h"Use fixed-width types at RISC OS and C ABI boundaries:
int32_t value;
uint32_t flags;
uintptr_t address;Use uintptr_t when converting pointers to integers. Be careful with
_kernel_swi_regs: 64-bit RISC OS headers may still represent SWI register
fields as 32-bit values.
C And RISC OS Interop
Use extern "C" for functions compiled as C or exported to C:
extern "C" int c_scale(int value, int multiplier);For headers included from both C and C++:
#ifdef __cplusplus
extern "C" {
#endif
int c_scale(int value, int multiplier);
#ifdef __cplusplus
}
#endifDo not expose C++ classes, references, overloaded functions, exceptions, or standard library types through C-callable interfaces.
RISC OS APIs often use C strings or control-terminated strings. Use C zero-terminated strings for normal C/C++ interfaces, and control-terminated strings only when the RISC OS API documents that convention.
Comments
Retain existing comments where they remain correct. Add comments to explain intent, not mechanical operations.
Use the project's existing file prologue style for new C++ source files:
/*******************************************************************
* File: name
* Purpose: Description
* Author: AUTHOR
******************************************************************/Do not use the bordered C function prologue format from the C skill for every C++ member function unless the local C++ project already does so.
Common Failures
If a build tries to produce or run 32-bit output, check that BUILD64=1 and
riscos-build-run --64 are both present.
If linking fails with missing C++ runtime symbols, check that ${C++LIB} is in
LIBS for makefile builds, or that direct links include -lsupc++ and the
C++ library object.
If code fails around exceptions, RTTI, templates, or modules, remove or isolate that feature before chasing unrelated build issues.
In this repository47 other files it gives its agents.
- allocating-resourcesSkill
- ci-testingSkill
- creating-pull-requestsSkill
- designing-modulesSkill
- porting-to-riscos-cSkill
- reading-assemblySkill
- riscos-commandsSkill
- riscos-desktop-fileractionSkill
- riscos-filer-likeSkill
- riscos-filesystemSkill
- riscos-graphics-convertersSkill
- riscos-network-dcistatisticsSkill
- riscos-network-resolverSkill
- riscos-outputSkill
- riscos-reSkill
- riscos-styleSkill
- riscos-throwbackSkill
- riscos-urls-fetchingSkill
- riscos-urls-launchingSkill
- riscos-wimp-appSkill
- riscos-wimpSkill
- riscos-wimp-templatesSkill
- updating-robe-skillsSkill
- using-bbcbasicSkill
- using-cmhgSkill
- using-ghSkill
- using-gitSkill
- using-libasmSkill
- using-libgcontextSkill
- using-liboslibSkill
- using-libriscoslibSkill
- using-libtoolboxSkill
- using-makefilesSkill
- using-perlSkill
- using-stronghelpSkill
- using-toolbox-imagefilegadgetSkill
- using-tooltesterSkill
- writing-assemblySkill
- writing-assembly-testsSkill
- writing-cmodulesSkill
- writing-cSkill
- writing-fortranSkill
- writing-oslib-defsSkill
- writing-pascalSkill
- writing-prminxmlSkill
- writing-pymodulesSkill
- writing-pyromaniac-integration-testsSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

