diff --git a/public/og/options-struct-links-every-setter.png b/public/og/options-struct-links-every-setter.png new file mode 100644 index 00000000..3eff9ac5 Binary files /dev/null and b/public/og/options-struct-links-every-setter.png differ diff --git a/scripts/schedule_doubles.py b/scripts/schedule_doubles.py index 6fb2de15..88135824 100644 --- a/scripts/schedule_doubles.py +++ b/scripts/schedule_doubles.py @@ -247,6 +247,8 @@ "why": "December safety roundup, beside the tidy-agent episode"}, "2026-12-13": {"slug": "contracts-on-a-microcontroller", "hour": 16, "why": "lvgl26 size finding on contracts, beside the RAII ffmpeg post"}, + "2026-12-16": {"slug": "options-struct-links-every-setter", "hour": 16, + "why": "lvgl26 size finding on options structs, beside the constexpr assembler flagship"}, } diff --git a/social/facebook/options-struct-links-every-setter/README.md b/social/facebook/options-struct-links-every-setter/README.md new file mode 100644 index 00000000..85dc2af2 --- /dev/null +++ b/social/facebook/options-struct-links-every-setter/README.md @@ -0,0 +1,130 @@ +# LinkedIn Square Post (1200x1200) + +Standard LinkedIn feed post at 1:1 square aspect ratio. Works well as a scroll-stopping image in the LinkedIn feed. + +## Usage + +```bash +brand-gen init social/linkedin-post my-post +cd my-post +# edit content.md +brand-gen build # -> index.html +brand-gen image # -> my-post.png (2400x2400 at 2x DPR) +``` + +## Directives + +All templates use one of four post types. Each uses the same directive pattern: + +### Quote + +```markdown +::::post{type=quote theme=dark logo=top-left} + +:::quote{author="Filip Sajdak" role="Founder & CEO, ScudoAI"} + +Sovereign AI is not a feature you bolt on later. It is the architecture. + +::: + +:::: +``` + +### Stat + +```markdown +::::post{type=stat theme=light accent=brand} + +:::stat{value="USD 80B" label="Worldwide sovereign cloud spend" context="Europe is the fastest-growing region at 83% YoY." source="Gartner, Feb 2026"} +::: + +:::: +``` + +### Announcement + +```markdown +::::post{type=announcement theme=light} + +:::announcement{kind="launch" date="April 2026"} + +# ScudoAI joins NVIDIA Inception + +We are thrilled to join the NVIDIA Inception program to accelerate sovereign AI deployment across European regulated industries. + +::: + +:::: +``` + +### Insight + +```markdown +::::post{type=insight theme=dark} + +:::insight{citation="EU AI Act full enforcement: 2 August 2026"} + +# The AI compliance deadline most companies are missing + +Full EU AI Act enforcement for high-risk AI systems begins in 2 August 2026. Most regulated enterprises are not ready for the documentation and audit requirements. Teams running cloud AI will face the hardest transition. + +::: + +:::: +``` + +## Attributes reference + +### `::::post` attributes + +- `type` - quote | stat | announcement | insight (required) +- `theme` - dark | light (default light) +- `accent` - brand | amber | nv (optional colored gradient background) +- `logo` - top-left | top-right | bottom-left | bottom-right (default bottom-right) + +### `:::quote` attributes + +- `author` - attribution name (appears below the quote) +- `role` - attribution role/title (appears under the author) + +### `:::stat` attributes + +- `value` - the big number (e.g. "USD 80B", "3/4", "Hours to minutes") +- `label` - short label under the value +- `context` - 1-2 sentences providing context +- `source` - small citation + +### `:::announcement` attributes + +- `kind` - launch | milestone | event | hire | partnership +- `date` - free-form date string + +### `:::insight` attributes + +- `citation` - small footer citation (e.g. regulation reference) + +## Character limits + +- **Quote body**: ~120 characters for maximum readability at thumbnail size +- **Stat label**: ~40 characters +- **Stat context**: ~200 characters +- **Announcement headline**: ~80 characters +- **Announcement body**: ~250 characters +- **Insight hook**: ~100 characters +- **Insight body**: ~300 characters + +Posts that exceed these limits will still render but typography may shrink or content may clip. + +## Media + +Add a `media/` directory to the project and reference local files: + +```markdown +:::background{image="nvidia-thor.jpg" overlay="dark"} +::: + +:::image{src="product-screenshot.png" alt="ScudoAI compliance dashboard" position="top"} +::: +``` + +Paths are relative to the project's `media/` directory. diff --git a/social/facebook/options-struct-links-every-setter/assets/brand-kit.json b/social/facebook/options-struct-links-every-setter/assets/brand-kit.json new file mode 100644 index 00000000..802d058e --- /dev/null +++ b/social/facebook/options-struct-links-every-setter/assets/brand-kit.json @@ -0,0 +1,11 @@ +{ + "template": "social/linkedin-post", + "bundleSource": "scudoai-social.css", + "brandKitVersion": "0.1.0", + "vendoredAt": "2026-11-29T14:04:01.837Z", + "files": [ + "scudoai.css", + "layout.css", + "logo-symbol.svg" + ] +} diff --git a/social/facebook/options-struct-links-every-setter/assets/layout.css b/social/facebook/options-struct-links-every-setter/assets/layout.css new file mode 100644 index 00000000..e69de29b diff --git a/social/facebook/options-struct-links-every-setter/assets/logo-symbol.svg b/social/facebook/options-struct-links-every-setter/assets/logo-symbol.svg new file mode 100644 index 00000000..1fc44966 --- /dev/null +++ b/social/facebook/options-struct-links-every-setter/assets/logo-symbol.svg @@ -0,0 +1,22 @@ + diff --git a/social/facebook/options-struct-links-every-setter/assets/scudoai.css b/social/facebook/options-struct-links-every-setter/assets/scudoai.css new file mode 100644 index 00000000..612b5a12 --- /dev/null +++ b/social/facebook/options-struct-links-every-setter/assets/scudoai.css @@ -0,0 +1,343 @@ +/* ============================================================ + * wro.cpp social card -- standalone stylesheet + * + * Self-contained styling for brand-gen's `social/linkedin-post` + * output. Replaces (does NOT extend) the scudoai-social.css that + * brand-gen ships with -- the design language here is the + * wro.cpp 'Editorial Magnet' look used by src/styles/global.css, + * not the scudoai blue-indigo deck aesthetic. + * + * Source of truth for tokens: src/styles/global.css:12-30 in the + * wrocpp.github.io repo. + * + * Brand-gen markup we style: + *
+ *
(decorative, hidden) + *
(decorative, hidden) + *
+ *

...

+ *

...

+ *
...
+ *
+ *
+ * + * ScudoAI (hidden; replaced via ::after) + *
+ *
+ * + * Other card types (card-quote, card-stat, card-announcement) + * get analogous rules at the bottom. + * ============================================================ */ + +@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=JetBrains+Mono:wght@400;500;700&display=swap'); + +:root { + --paper: #FCFAF5; + --paper-2: #F3EFE6; + --paper-3: #E8E1D0; + --ink: #1B1B1D; + --ink-muted:#55555A; + --ink-faint:#8A8A90; + --rule: #D7D2C4; + --orange: #EA541E; + --orange-2: #D6481A; + --blue: #3EB5E9; + --blue-deep:#2E8FB8; + + --font-display: 'Quicksand', system-ui, -apple-system, sans-serif; + --font-body: 'Source Serif 4', Georgia, serif; + --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; +} + +html, body { + margin: 0; + padding: 0; + background: var(--paper); + color: var(--ink); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-family: var(--font-body); + font-size: 18px; + line-height: 1.6; +} + +/* Hide brand-gen decorative noise -- the wro.cpp aesthetic is calm + * and editorial, not a dark deck with glow + grid backgrounds. */ +.grid-bg, .glow { display: none !important; } + +/* ---------------- Card frame (1200x1200) ---------------- */ +.card { + position: relative; + width: 1200px; + height: 1200px; + background: var(--paper); + /* Faint warm radial wash, mirrors body { background-image } in + * src/styles/global.css:44-49 -- gives the paper texture without + * looking flat. */ + background-image: + radial-gradient(900px 700px at 80% -10%, rgba(234, 84, 30, 0.06), transparent 60%), + radial-gradient(800px 600px at -10% 110%, rgba(62, 181, 233, 0.05), transparent 60%); + overflow: hidden; + box-sizing: border-box; + padding: 130px 110px 130px 110px; + display: flex; + flex-direction: column; + /* Faint inner border gives the card a printed-page feel. */ + border-bottom: 6px solid var(--orange); +} + +/* Override: theme=dark cards still use paper. We keep the editorial + * light look across the board so the wro.cpp brand stays consistent. + * If the user really wants a dark variant later, this is the hook. */ +.card.dark { background: var(--paper) !important; color: var(--ink) !important; } +.card.dark h1, .card.dark h2, .card.dark p, +.card.dark blockquote { color: var(--ink) !important; } + +/* ---------------- INSIGHT card ---------------- */ +.card-insight { + justify-content: center; + padding-top: 200px; /* reserve space for logo watermark (top:90px + 64px + safety) */ +} +.card-insight .insight-content { + display: flex; + flex-direction: column; + gap: 60px; + max-width: 980px; +} +.card-insight h1 { + font-family: var(--font-display); + font-weight: 700; + font-size: 92pt; + line-height: 1.02; + letter-spacing: -0.025em; + color: var(--ink); + margin: 0; +} +.card-insight h1.title-long { + font-size: 72pt; + line-height: 1.06; + letter-spacing: -0.02em; + max-height: 420px; +} +.card-insight h1.title-xlong { + font-size: 56pt; + line-height: 1.10; + letter-spacing: -0.015em; + max-height: 440px; +} +/* Auto-accent: ++ in C++/C++26 turns orange, sentence-final period + * (when wrapped in ) turns blue. The skill writes + * the heading with these spans for the wro.cpp signature look. */ +.card-insight h1 .accent { color: var(--orange); } +.card-insight h1 .dot { color: var(--blue-deep); } +.card-insight p { + font-family: var(--font-body); + font-size: 30pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 0; + max-width: 920px; +} +.card-insight .insight-citation { + font-family: var(--font-mono); + font-size: 18pt; + letter-spacing: 0.04em; + color: var(--ink-faint); + margin-top: 40px; + padding-top: 30px; + border-top: 1px solid var(--rule); + text-transform: lowercase; +} +.card-insight .insight-citation::before { + content: '// '; + color: var(--orange); + font-weight: 700; +} + +/* ---------------- QUOTE card ---------------- */ +.card-quote { justify-content: center; padding: 140px 110px; } +.card-quote .quote-content { display: flex; flex-direction: column; align-items: flex-start; } +.card-quote .quote-mark { + font-family: var(--font-display); + font-weight: 700; + font-size: 200pt; + line-height: 0.8; + color: var(--orange); + opacity: 0.20; + /* In-flow above the text (not floated in the corner) with a negative + * bottom margin so the mark nearly touches the first quote line. */ + margin: 0 0 -0.62em; +} +.card-quote .quote-body { + font-family: var(--font-display); + font-weight: 600; + font-size: 64pt; + line-height: 1.15; + letter-spacing: -0.02em; + color: var(--ink); + max-width: 980px; + margin: 0; +} +.card-quote .quote-attribution { + margin-top: 50px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-muted); +} +.card-quote .quote-attribution::before { content: '-- '; color: var(--orange); } +/* author and role are adjacent spans with no separator in the markup; + * add one so they do not run together ("wro.cppC++26 ..."). */ +.card-quote .quote-attribution .role::before { content: ' / '; color: var(--ink-faint); } + +/* ---------------- STAT card ---------------- */ +.card-stat { justify-content: center; } +/* Value and label sit side by side (label wraps to stacked lines whose + * combined height roughly matches the value); context + source span the + * full width underneath. */ +.card-stat .stat-content { + display: grid; + grid-template-columns: auto 1fr; + grid-template-areas: + "value label" + "context context" + "source source"; + column-gap: 64px; + align-items: center; +} +.card-stat .stat-value { + grid-area: value; + font-family: var(--font-display); + font-weight: 700; + font-size: 240pt; + line-height: 0.82; + letter-spacing: -0.04em; + color: var(--orange); + margin: 0; +} +.card-stat .stat-label { + grid-area: label; + font-family: var(--font-display); + font-weight: 700; + font-size: 90pt; + line-height: 1.0; + letter-spacing: -0.02em; + color: var(--ink); + /* min-content forces a per-word wrap, so "codegen steps" stacks into + * two lines next to the value instead of running on one long line. */ + width: min-content; + margin: 0; +} +.card-stat .stat-context { + grid-area: context; + font-family: var(--font-body); + font-size: 26pt; + line-height: 1.45; + color: var(--ink-muted); + margin: 56px 0 0; + max-width: 880px; +} +.card-stat .stat-source { + grid-area: source; + margin-top: 44px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-faint); +} +.card-stat .stat-source::before { content: '// '; color: var(--orange); } + +/* ---------------- ANNOUNCEMENT card ---------------- */ +.card-announcement { justify-content: center; } +.card-announcement .announcement-meta { + font-family: var(--font-mono); + font-size: 20pt; + text-transform: uppercase; + letter-spacing: 0.08em; + color: var(--orange); + margin-bottom: 30px; +} +.card-announcement .announcement-content h1, +.card-announcement .announcement-content h2 { + font-family: var(--font-display); + font-weight: 700; + font-size: 78pt; + line-height: 1.05; + letter-spacing: -0.02em; + color: var(--ink); + margin: 0; +} +.card-announcement .announcement-content p { + font-family: var(--font-body); + font-size: 28pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 40px 0 0; + max-width: 900px; +} + +/* ---------------- LOGO WATERMARK ---------------- */ +/* brand-gen hard-codes "ScudoAI" in .logo-wordmark; we hide it and + * draw "wro.cpp" via ::after on the watermark. The orange ".cpp" mirrors + * the brand-mark in the site header. */ +.logo-watermark { + position: absolute; + display: flex; + align-items: center; + gap: 18px; + height: 64px; + z-index: 10; + color: var(--ink); +} +.logo-watermark.top-left { top: 90px; left: 110px; } +.logo-watermark.top-right { top: 90px; right: 110px; } +.logo-watermark.bottom-left { bottom: 60px; left: 110px; } +.logo-watermark.bottom-right { bottom: 60px; right: 110px; } +.logo-watermark svg { + width: 64px; + height: 64px; + flex-shrink: 0; + /* Magnet logo PNG already has transparent paper-tone background; + * no rounded box needed -- it sits on the paper card directly. */ +} +.logo-wordmark { + font-size: 0 !important; + line-height: 0 !important; + /* Hide the upstream "ScudoAI" text node entirely. */ +} +.logo-watermark::after { + content: 'wro.cpp'; + font-family: var(--font-display); + font-weight: 700; + font-size: 28pt; + letter-spacing: -0.025em; + color: var(--ink); + line-height: 1; + /* The .cpp portion is given orange via a ::first-line trick below + * isn't reliable for inline -- so the SKILL writes the wordmark + * with explicit spans when it owns the markup. For this default + * rendering, the whole wordmark is ink and the orange comes through + * the bottom border + eyebrow. */ +} +.logo-watermark.top-right::after, +.logo-watermark.bottom-right::after { order: -1; margin-right: 18px; } + +/* ---------------- AI DISCLOSURE BADGE ---------------- */ +/* A small, honest "AI-GENERATED" label so the disclosure rides with the + * card image on social. Bottom-right corner (logo is top-left, citation is + * center-bottom, so this corner is free). Injected into index.html by + * inject.sh. See the /ai policy page. */ +.ai-badge { + position: absolute; + bottom: 74px; /* clears the 6px orange accent bar; sits in the bottom padding band */ + right: 110px; /* matches the card side padding / logo inset */ + z-index: 10; + font-family: var(--font-mono); + font-size: 14pt; + font-weight: 500; + letter-spacing: 0.10em; + text-transform: uppercase; + color: var(--ink-faint); +} + +/* ---------------- Defensive overrides ---------------- */ +/* Anything brand-gen might have set inline using its tokens. */ +* { box-sizing: border-box; } diff --git a/social/facebook/options-struct-links-every-setter/caption.md b/social/facebook/options-struct-links-every-setter/caption.md new file mode 100644 index 00000000..b475272d --- /dev/null +++ b/social/facebook/options-struct-links-every-setter/caption.md @@ -0,0 +1,16 @@ +# At -Os, an options struct links every setter + +## Body +Set one property through an options struct, and the linker can keep every setter of the widget. On ARM GCC 16.2 at -Os a demo dial kept 6 of 6 setters; naming the member as a template argument kept 1. At -O2 both kept 1. In lvgl26, my C++26 layer over LVGL, the change was 34,024 B of flash. lvgl26 is written by Filip Sajdak, who runs this blog. + +https://wrocpp.github.io/posts/options-struct-links-every-setter/ + +## Hashtags +#cpp #cpp26 #embedded #wrocpp + +## Alt-text +wro.cpp card with the magnet logo. Headline reads "At -Os, one option set links six setters" with a subtitle about an options struct on ARM GCC 16.2 at -Os and 34,024 B of flash in lvgl26. Citation footer: wro.cpp, 2026-12-16. + +## Suggested post time +Wednesday 2026-12-16, 16:00 UTC +Reason: the second slot of the day, beside the 08:00 UTC constexpr assembler post. diff --git a/social/facebook/options-struct-links-every-setter/config.yaml b/social/facebook/options-struct-links-every-setter/config.yaml new file mode 100644 index 00000000..dde6b1ff --- /dev/null +++ b/social/facebook/options-struct-links-every-setter/config.yaml @@ -0,0 +1,12 @@ +template: social/linkedin-post + +size: + width: 1200 + height: 1200 + dpr: 2 + +project: + name: "options-struct-links-every-setter" + author: "Filip Sajdak, Founder & CEO" + email: "office@scudoai.com" + date: "2026-12-16" diff --git a/social/facebook/options-struct-links-every-setter/content.md b/social/facebook/options-struct-links-every-setter/content.md new file mode 100644 index 00000000..37cf535f --- /dev/null +++ b/social/facebook/options-struct-links-every-setter/content.md @@ -0,0 +1,12 @@ +--- +template: social/linkedin-post +--- + +::::post{type=insight theme=dark logo=top-left} + +:::insight{citation="wro.cpp -- 2026-12-16"} +# At -Os, one option set links six setters +On ARM GCC 16.2 at -Os, an options struct applied at run time kept every setter in the binary. Naming the member at compile time kept one. In lvgl26 the change was 34,024 B of flash. +::: + +:::: diff --git a/social/facebook/options-struct-links-every-setter/image.png b/social/facebook/options-struct-links-every-setter/image.png new file mode 100644 index 00000000..957d7eff Binary files /dev/null and b/social/facebook/options-struct-links-every-setter/image.png differ diff --git a/social/facebook/options-struct-links-every-setter/index.html b/social/facebook/options-struct-links-every-setter/index.html new file mode 100644 index 00000000..7382471e --- /dev/null +++ b/social/facebook/options-struct-links-every-setter/index.html @@ -0,0 +1,28 @@ + + + + + + options-struct-links-every-setter + + + + + + + + + + +

At -Os, one option set links six setters

On ARM GCC 16.2 at -Os, an options struct applied at run time kept every setter in the binary. Naming the member at compile time kept one. In lvgl26 the change was 34,024 B of flash.

wro.cpp -- 2026-12-16
ScudoAI
AI-generated
+ + \ No newline at end of file diff --git a/social/facebook/options-struct-links-every-setter/media/.gitkeep b/social/facebook/options-struct-links-every-setter/media/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/social/facebook/options-struct-links-every-setter/media/README.md b/social/facebook/options-struct-links-every-setter/media/README.md new file mode 100644 index 00000000..bb81c7fa --- /dev/null +++ b/social/facebook/options-struct-links-every-setter/media/README.md @@ -0,0 +1,9 @@ +# Media directory + +Drop images here (PNG, JPG, SVG) for use in your post. + +Reference them in your content.md with: + + :::image{src="screenshot.png" alt="Alt text" position="top"} + +The renderer resolves paths relative to this media/ directory. diff --git a/social/linkedin/options-struct-links-every-setter/README.md b/social/linkedin/options-struct-links-every-setter/README.md new file mode 100644 index 00000000..85dc2af2 --- /dev/null +++ b/social/linkedin/options-struct-links-every-setter/README.md @@ -0,0 +1,130 @@ +# LinkedIn Square Post (1200x1200) + +Standard LinkedIn feed post at 1:1 square aspect ratio. Works well as a scroll-stopping image in the LinkedIn feed. + +## Usage + +```bash +brand-gen init social/linkedin-post my-post +cd my-post +# edit content.md +brand-gen build # -> index.html +brand-gen image # -> my-post.png (2400x2400 at 2x DPR) +``` + +## Directives + +All templates use one of four post types. Each uses the same directive pattern: + +### Quote + +```markdown +::::post{type=quote theme=dark logo=top-left} + +:::quote{author="Filip Sajdak" role="Founder & CEO, ScudoAI"} + +Sovereign AI is not a feature you bolt on later. It is the architecture. + +::: + +:::: +``` + +### Stat + +```markdown +::::post{type=stat theme=light accent=brand} + +:::stat{value="USD 80B" label="Worldwide sovereign cloud spend" context="Europe is the fastest-growing region at 83% YoY." source="Gartner, Feb 2026"} +::: + +:::: +``` + +### Announcement + +```markdown +::::post{type=announcement theme=light} + +:::announcement{kind="launch" date="April 2026"} + +# ScudoAI joins NVIDIA Inception + +We are thrilled to join the NVIDIA Inception program to accelerate sovereign AI deployment across European regulated industries. + +::: + +:::: +``` + +### Insight + +```markdown +::::post{type=insight theme=dark} + +:::insight{citation="EU AI Act full enforcement: 2 August 2026"} + +# The AI compliance deadline most companies are missing + +Full EU AI Act enforcement for high-risk AI systems begins in 2 August 2026. Most regulated enterprises are not ready for the documentation and audit requirements. Teams running cloud AI will face the hardest transition. + +::: + +:::: +``` + +## Attributes reference + +### `::::post` attributes + +- `type` - quote | stat | announcement | insight (required) +- `theme` - dark | light (default light) +- `accent` - brand | amber | nv (optional colored gradient background) +- `logo` - top-left | top-right | bottom-left | bottom-right (default bottom-right) + +### `:::quote` attributes + +- `author` - attribution name (appears below the quote) +- `role` - attribution role/title (appears under the author) + +### `:::stat` attributes + +- `value` - the big number (e.g. "USD 80B", "3/4", "Hours to minutes") +- `label` - short label under the value +- `context` - 1-2 sentences providing context +- `source` - small citation + +### `:::announcement` attributes + +- `kind` - launch | milestone | event | hire | partnership +- `date` - free-form date string + +### `:::insight` attributes + +- `citation` - small footer citation (e.g. regulation reference) + +## Character limits + +- **Quote body**: ~120 characters for maximum readability at thumbnail size +- **Stat label**: ~40 characters +- **Stat context**: ~200 characters +- **Announcement headline**: ~80 characters +- **Announcement body**: ~250 characters +- **Insight hook**: ~100 characters +- **Insight body**: ~300 characters + +Posts that exceed these limits will still render but typography may shrink or content may clip. + +## Media + +Add a `media/` directory to the project and reference local files: + +```markdown +:::background{image="nvidia-thor.jpg" overlay="dark"} +::: + +:::image{src="product-screenshot.png" alt="ScudoAI compliance dashboard" position="top"} +::: +``` + +Paths are relative to the project's `media/` directory. diff --git a/social/linkedin/options-struct-links-every-setter/assets/brand-kit.json b/social/linkedin/options-struct-links-every-setter/assets/brand-kit.json new file mode 100644 index 00000000..603185f1 --- /dev/null +++ b/social/linkedin/options-struct-links-every-setter/assets/brand-kit.json @@ -0,0 +1,11 @@ +{ + "template": "social/linkedin-post", + "bundleSource": "scudoai-social.css", + "brandKitVersion": "0.1.0", + "vendoredAt": "2026-11-29T14:04:01.695Z", + "files": [ + "scudoai.css", + "layout.css", + "logo-symbol.svg" + ] +} diff --git a/social/linkedin/options-struct-links-every-setter/assets/layout.css b/social/linkedin/options-struct-links-every-setter/assets/layout.css new file mode 100644 index 00000000..e69de29b diff --git a/social/linkedin/options-struct-links-every-setter/assets/logo-symbol.svg b/social/linkedin/options-struct-links-every-setter/assets/logo-symbol.svg new file mode 100644 index 00000000..1fc44966 --- /dev/null +++ b/social/linkedin/options-struct-links-every-setter/assets/logo-symbol.svg @@ -0,0 +1,22 @@ + diff --git a/social/linkedin/options-struct-links-every-setter/assets/scudoai.css b/social/linkedin/options-struct-links-every-setter/assets/scudoai.css new file mode 100644 index 00000000..612b5a12 --- /dev/null +++ b/social/linkedin/options-struct-links-every-setter/assets/scudoai.css @@ -0,0 +1,343 @@ +/* ============================================================ + * wro.cpp social card -- standalone stylesheet + * + * Self-contained styling for brand-gen's `social/linkedin-post` + * output. Replaces (does NOT extend) the scudoai-social.css that + * brand-gen ships with -- the design language here is the + * wro.cpp 'Editorial Magnet' look used by src/styles/global.css, + * not the scudoai blue-indigo deck aesthetic. + * + * Source of truth for tokens: src/styles/global.css:12-30 in the + * wrocpp.github.io repo. + * + * Brand-gen markup we style: + *
+ *
(decorative, hidden) + *
(decorative, hidden) + *
+ *

...

+ *

...

+ *
...
+ *
+ *
+ * + * ScudoAI (hidden; replaced via ::after) + *
+ *
+ * + * Other card types (card-quote, card-stat, card-announcement) + * get analogous rules at the bottom. + * ============================================================ */ + +@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=JetBrains+Mono:wght@400;500;700&display=swap'); + +:root { + --paper: #FCFAF5; + --paper-2: #F3EFE6; + --paper-3: #E8E1D0; + --ink: #1B1B1D; + --ink-muted:#55555A; + --ink-faint:#8A8A90; + --rule: #D7D2C4; + --orange: #EA541E; + --orange-2: #D6481A; + --blue: #3EB5E9; + --blue-deep:#2E8FB8; + + --font-display: 'Quicksand', system-ui, -apple-system, sans-serif; + --font-body: 'Source Serif 4', Georgia, serif; + --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; +} + +html, body { + margin: 0; + padding: 0; + background: var(--paper); + color: var(--ink); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-family: var(--font-body); + font-size: 18px; + line-height: 1.6; +} + +/* Hide brand-gen decorative noise -- the wro.cpp aesthetic is calm + * and editorial, not a dark deck with glow + grid backgrounds. */ +.grid-bg, .glow { display: none !important; } + +/* ---------------- Card frame (1200x1200) ---------------- */ +.card { + position: relative; + width: 1200px; + height: 1200px; + background: var(--paper); + /* Faint warm radial wash, mirrors body { background-image } in + * src/styles/global.css:44-49 -- gives the paper texture without + * looking flat. */ + background-image: + radial-gradient(900px 700px at 80% -10%, rgba(234, 84, 30, 0.06), transparent 60%), + radial-gradient(800px 600px at -10% 110%, rgba(62, 181, 233, 0.05), transparent 60%); + overflow: hidden; + box-sizing: border-box; + padding: 130px 110px 130px 110px; + display: flex; + flex-direction: column; + /* Faint inner border gives the card a printed-page feel. */ + border-bottom: 6px solid var(--orange); +} + +/* Override: theme=dark cards still use paper. We keep the editorial + * light look across the board so the wro.cpp brand stays consistent. + * If the user really wants a dark variant later, this is the hook. */ +.card.dark { background: var(--paper) !important; color: var(--ink) !important; } +.card.dark h1, .card.dark h2, .card.dark p, +.card.dark blockquote { color: var(--ink) !important; } + +/* ---------------- INSIGHT card ---------------- */ +.card-insight { + justify-content: center; + padding-top: 200px; /* reserve space for logo watermark (top:90px + 64px + safety) */ +} +.card-insight .insight-content { + display: flex; + flex-direction: column; + gap: 60px; + max-width: 980px; +} +.card-insight h1 { + font-family: var(--font-display); + font-weight: 700; + font-size: 92pt; + line-height: 1.02; + letter-spacing: -0.025em; + color: var(--ink); + margin: 0; +} +.card-insight h1.title-long { + font-size: 72pt; + line-height: 1.06; + letter-spacing: -0.02em; + max-height: 420px; +} +.card-insight h1.title-xlong { + font-size: 56pt; + line-height: 1.10; + letter-spacing: -0.015em; + max-height: 440px; +} +/* Auto-accent: ++ in C++/C++26 turns orange, sentence-final period + * (when wrapped in ) turns blue. The skill writes + * the heading with these spans for the wro.cpp signature look. */ +.card-insight h1 .accent { color: var(--orange); } +.card-insight h1 .dot { color: var(--blue-deep); } +.card-insight p { + font-family: var(--font-body); + font-size: 30pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 0; + max-width: 920px; +} +.card-insight .insight-citation { + font-family: var(--font-mono); + font-size: 18pt; + letter-spacing: 0.04em; + color: var(--ink-faint); + margin-top: 40px; + padding-top: 30px; + border-top: 1px solid var(--rule); + text-transform: lowercase; +} +.card-insight .insight-citation::before { + content: '// '; + color: var(--orange); + font-weight: 700; +} + +/* ---------------- QUOTE card ---------------- */ +.card-quote { justify-content: center; padding: 140px 110px; } +.card-quote .quote-content { display: flex; flex-direction: column; align-items: flex-start; } +.card-quote .quote-mark { + font-family: var(--font-display); + font-weight: 700; + font-size: 200pt; + line-height: 0.8; + color: var(--orange); + opacity: 0.20; + /* In-flow above the text (not floated in the corner) with a negative + * bottom margin so the mark nearly touches the first quote line. */ + margin: 0 0 -0.62em; +} +.card-quote .quote-body { + font-family: var(--font-display); + font-weight: 600; + font-size: 64pt; + line-height: 1.15; + letter-spacing: -0.02em; + color: var(--ink); + max-width: 980px; + margin: 0; +} +.card-quote .quote-attribution { + margin-top: 50px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-muted); +} +.card-quote .quote-attribution::before { content: '-- '; color: var(--orange); } +/* author and role are adjacent spans with no separator in the markup; + * add one so they do not run together ("wro.cppC++26 ..."). */ +.card-quote .quote-attribution .role::before { content: ' / '; color: var(--ink-faint); } + +/* ---------------- STAT card ---------------- */ +.card-stat { justify-content: center; } +/* Value and label sit side by side (label wraps to stacked lines whose + * combined height roughly matches the value); context + source span the + * full width underneath. */ +.card-stat .stat-content { + display: grid; + grid-template-columns: auto 1fr; + grid-template-areas: + "value label" + "context context" + "source source"; + column-gap: 64px; + align-items: center; +} +.card-stat .stat-value { + grid-area: value; + font-family: var(--font-display); + font-weight: 700; + font-size: 240pt; + line-height: 0.82; + letter-spacing: -0.04em; + color: var(--orange); + margin: 0; +} +.card-stat .stat-label { + grid-area: label; + font-family: var(--font-display); + font-weight: 700; + font-size: 90pt; + line-height: 1.0; + letter-spacing: -0.02em; + color: var(--ink); + /* min-content forces a per-word wrap, so "codegen steps" stacks into + * two lines next to the value instead of running on one long line. */ + width: min-content; + margin: 0; +} +.card-stat .stat-context { + grid-area: context; + font-family: var(--font-body); + font-size: 26pt; + line-height: 1.45; + color: var(--ink-muted); + margin: 56px 0 0; + max-width: 880px; +} +.card-stat .stat-source { + grid-area: source; + margin-top: 44px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-faint); +} +.card-stat .stat-source::before { content: '// '; color: var(--orange); } + +/* ---------------- ANNOUNCEMENT card ---------------- */ +.card-announcement { justify-content: center; } +.card-announcement .announcement-meta { + font-family: var(--font-mono); + font-size: 20pt; + text-transform: uppercase; + letter-spacing: 0.08em; + color: var(--orange); + margin-bottom: 30px; +} +.card-announcement .announcement-content h1, +.card-announcement .announcement-content h2 { + font-family: var(--font-display); + font-weight: 700; + font-size: 78pt; + line-height: 1.05; + letter-spacing: -0.02em; + color: var(--ink); + margin: 0; +} +.card-announcement .announcement-content p { + font-family: var(--font-body); + font-size: 28pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 40px 0 0; + max-width: 900px; +} + +/* ---------------- LOGO WATERMARK ---------------- */ +/* brand-gen hard-codes "ScudoAI" in .logo-wordmark; we hide it and + * draw "wro.cpp" via ::after on the watermark. The orange ".cpp" mirrors + * the brand-mark in the site header. */ +.logo-watermark { + position: absolute; + display: flex; + align-items: center; + gap: 18px; + height: 64px; + z-index: 10; + color: var(--ink); +} +.logo-watermark.top-left { top: 90px; left: 110px; } +.logo-watermark.top-right { top: 90px; right: 110px; } +.logo-watermark.bottom-left { bottom: 60px; left: 110px; } +.logo-watermark.bottom-right { bottom: 60px; right: 110px; } +.logo-watermark svg { + width: 64px; + height: 64px; + flex-shrink: 0; + /* Magnet logo PNG already has transparent paper-tone background; + * no rounded box needed -- it sits on the paper card directly. */ +} +.logo-wordmark { + font-size: 0 !important; + line-height: 0 !important; + /* Hide the upstream "ScudoAI" text node entirely. */ +} +.logo-watermark::after { + content: 'wro.cpp'; + font-family: var(--font-display); + font-weight: 700; + font-size: 28pt; + letter-spacing: -0.025em; + color: var(--ink); + line-height: 1; + /* The .cpp portion is given orange via a ::first-line trick below + * isn't reliable for inline -- so the SKILL writes the wordmark + * with explicit spans when it owns the markup. For this default + * rendering, the whole wordmark is ink and the orange comes through + * the bottom border + eyebrow. */ +} +.logo-watermark.top-right::after, +.logo-watermark.bottom-right::after { order: -1; margin-right: 18px; } + +/* ---------------- AI DISCLOSURE BADGE ---------------- */ +/* A small, honest "AI-GENERATED" label so the disclosure rides with the + * card image on social. Bottom-right corner (logo is top-left, citation is + * center-bottom, so this corner is free). Injected into index.html by + * inject.sh. See the /ai policy page. */ +.ai-badge { + position: absolute; + bottom: 74px; /* clears the 6px orange accent bar; sits in the bottom padding band */ + right: 110px; /* matches the card side padding / logo inset */ + z-index: 10; + font-family: var(--font-mono); + font-size: 14pt; + font-weight: 500; + letter-spacing: 0.10em; + text-transform: uppercase; + color: var(--ink-faint); +} + +/* ---------------- Defensive overrides ---------------- */ +/* Anything brand-gen might have set inline using its tokens. */ +* { box-sizing: border-box; } diff --git a/social/linkedin/options-struct-links-every-setter/caption.md b/social/linkedin/options-struct-links-every-setter/caption.md new file mode 100644 index 00000000..4d5e2668 --- /dev/null +++ b/social/linkedin/options-struct-links-every-setter/caption.md @@ -0,0 +1,24 @@ +# At -Os, an options struct links every setter + +## Body +A program that sets one property through an options struct can link every setter of the widget. + +The demo has a dial with six optional members and an apply function that tests each one at run time. Which members the caller wrote is data, so every branch names its setter, and the linker keeps all six. A template that takes the member names as template arguments, set<&dial_options::value>(w, v), names one setter and links one. + +I linked both on ARM GCC 16.2 for a Cortex-M4. At -Os the struct form kept 6 of 6 setters, the named form 1. At -O2 GCC inlined the small apply function and folded the branches, so both kept 1. Measure with the options you ship. + +In lvgl26, my C++26 layer over LVGL, the same change to one line was 34,024 B of flash and 3,600 B of RAM on the Cortex-M4 slice. Most of that was contract checks that came with the setters. With the contract settings lvgl26 ships now, the struct form still costs 15,392 B of flash. + +The post has both forms on Compiler Explorer, the link table and the lvgl26 numbers. lvgl26 is written by Filip Sajdak, who runs this blog. + +https://wrocpp.github.io/posts/options-struct-links-every-setter/ + +## Hashtags +#cpp #cpp26 #embedded #apidesign #microcontrollers #wrocpp + +## Alt-text +wro.cpp card with the magnet logo. Headline reads "At -Os, one option set links six setters" with a subtitle about an options struct on ARM GCC 16.2 at -Os and 34,024 B of flash in lvgl26. Citation footer: wro.cpp, 2026-12-16. + +## Suggested post time +Wednesday 2026-12-16, 16:00 UTC +Reason: the second slot of the day, beside the 08:00 UTC constexpr assembler post. diff --git a/social/linkedin/options-struct-links-every-setter/config.yaml b/social/linkedin/options-struct-links-every-setter/config.yaml new file mode 100644 index 00000000..dde6b1ff --- /dev/null +++ b/social/linkedin/options-struct-links-every-setter/config.yaml @@ -0,0 +1,12 @@ +template: social/linkedin-post + +size: + width: 1200 + height: 1200 + dpr: 2 + +project: + name: "options-struct-links-every-setter" + author: "Filip Sajdak, Founder & CEO" + email: "office@scudoai.com" + date: "2026-12-16" diff --git a/social/linkedin/options-struct-links-every-setter/content.md b/social/linkedin/options-struct-links-every-setter/content.md new file mode 100644 index 00000000..37cf535f --- /dev/null +++ b/social/linkedin/options-struct-links-every-setter/content.md @@ -0,0 +1,12 @@ +--- +template: social/linkedin-post +--- + +::::post{type=insight theme=dark logo=top-left} + +:::insight{citation="wro.cpp -- 2026-12-16"} +# At -Os, one option set links six setters +On ARM GCC 16.2 at -Os, an options struct applied at run time kept every setter in the binary. Naming the member at compile time kept one. In lvgl26 the change was 34,024 B of flash. +::: + +:::: diff --git a/social/linkedin/options-struct-links-every-setter/image.png b/social/linkedin/options-struct-links-every-setter/image.png new file mode 100644 index 00000000..3eff9ac5 Binary files /dev/null and b/social/linkedin/options-struct-links-every-setter/image.png differ diff --git a/social/linkedin/options-struct-links-every-setter/index.html b/social/linkedin/options-struct-links-every-setter/index.html new file mode 100644 index 00000000..7382471e --- /dev/null +++ b/social/linkedin/options-struct-links-every-setter/index.html @@ -0,0 +1,28 @@ + + + + + + options-struct-links-every-setter + + + + + + + + + + +

At -Os, one option set links six setters

On ARM GCC 16.2 at -Os, an options struct applied at run time kept every setter in the binary. Naming the member at compile time kept one. In lvgl26 the change was 34,024 B of flash.

wro.cpp -- 2026-12-16
ScudoAI
AI-generated
+ + \ No newline at end of file diff --git a/social/linkedin/options-struct-links-every-setter/media/.gitkeep b/social/linkedin/options-struct-links-every-setter/media/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/social/linkedin/options-struct-links-every-setter/media/README.md b/social/linkedin/options-struct-links-every-setter/media/README.md new file mode 100644 index 00000000..bb81c7fa --- /dev/null +++ b/social/linkedin/options-struct-links-every-setter/media/README.md @@ -0,0 +1,9 @@ +# Media directory + +Drop images here (PNG, JPG, SVG) for use in your post. + +Reference them in your content.md with: + + :::image{src="screenshot.png" alt="Alt text" position="top"} + +The renderer resolves paths relative to this media/ directory. diff --git a/src/content/posts/2026-12-16-options-struct-links-every-setter.mdx b/src/content/posts/2026-12-16-options-struct-links-every-setter.mdx new file mode 100644 index 00000000..fe5e3a39 --- /dev/null +++ b/src/content/posts/2026-12-16-options-struct-links-every-setter.mdx @@ -0,0 +1,127 @@ +--- +title: "At -Os, an options struct links every setter" +slug: "options-struct-links-every-setter" +pubDate: 2026-12-16 +author: filip-sajdak +language: en +kind: short +audience: working-cpp +tags: [embedded, api-design, designated-initializers, cpp26] +summary: "A function that applies a struct of optional members tests each one at run time, so the linker keeps every setter. On ARM GCC 16.2 at -Os, setting one member kept six setters out of six. Naming the member as a template argument kept one. In lvgl26 that change was 34,024 B of flash." +draft: false +relatedPosts: [structured-binding-pack-lto-crash, tidy-agent-default-then-assign, define-aggregate] +--- + +import GodboltEmbed from '../../components/GodboltEmbed.astro'; +import PostLink from '../../components/PostLink.astro'; + +A program that set one property through an options struct linked all six setters of the widget. I built it with ARM GCC 16.2 at `-Os` for a Cortex-M4. The same program with the property named as a template argument linked one setter. In lvgl26, my C++26 layer over the LVGL graphics library, the same change to one line saved 34,024 B of flash. + +## In short + +- An apply function that reads an options struct at run time has one branch per member. Each branch calls a setter, so `--gc-sections` keeps every setter. +- A template that takes the member names as template arguments calls only their setters. +- At `-O2`, or with the apply function forced inline, GCC folded the branches of a small struct, and the struct form kept one setter too. At `-Os` it did not inline it. +- In lvgl26 the struct form cost 34,024 B of flash and 3,600 B of RAM, most of it in contract checks. With the contract settings lvgl26 ships now, it still costs 15,392 B of flash. + +lvgl26 is written by Filip Sajdak, who runs this blog. Status: lvgl26 0.0.1 is a preview, builds with GCC 16.2 only, and its size numbers come from a Cortex-M4 run in QEMU. + +## What to do + +1. **Count the setters in the linked binary.** Run `nm -C` on the ELF and grep for the setter prefix. One property set should not bring in every setter of the type. +2. **For size-bound code, pass the member names at compile time.** A pack of member pointers or names, as below, links only what the call names. Keep the options struct for code that is not size-bound, and document that it links every setter. +3. **Do not trust an `-O2` test for an `-Os` build.** The demo below folds at `-O2` and keeps everything at `-Os`. Measure with the options you ship. + +## Two ways to set a dial + +The demo has six setters, declared `[[gnu::noipa]]` so that they stay calls, as the functions of a library in another file do. Each optional member carries its setter in its type: + +```cpp +template +struct option { + std::optional given; + constexpr option() = default; + constexpr option(int v) : given{v} {} +}; + +struct dial_options { + option value{}; + option min{}; + option max{}; + option width{}; + option height{}; + option rotation{}; +}; +``` + +The run-time form reads the struct. Which members the caller wrote is data, so every member gets a test and a call: + +```cpp +void apply(widget* w, const dial_options& o) { + apply_one(w, o.value); // if (o.value.given) set_value(w, *o.value.given); + apply_one(w, o.min); + // ... and so on for all six members +} + +apply(w, {.value = v}); +``` + +The compile-time form takes the members as template arguments. A partial specialization reads the setter out of the type of each member pointer: + +```cpp +template +void set(widget* w, std::same_as auto... values) + requires(sizeof...(Members) == sizeof...(values)) +{ + (setter_of::function(w, values), ...); +} + +set<&dial_options::value>(w, v); +set<&dial_options::min, &dial_options::max>(w, 0, v); +``` + +The assembly for the Cortex-M4 at `-Os` shows the difference. The `apply` function calls all six setters. The caller of the struct form writes a 48-byte struct on the stack and calls `apply`. The caller of the named form is one branch to `set_value`. + + + +The same file runs on x86-64 GCC 16.2 and prints the six calls the two forms make: + + + +## What the linker kept + +Compiler Explorer shows assembly, not a linked program, so I linked three one-call programs locally. I used arm-none-eabi-g++ 16.2.0 with newlib, `-ffunction-sections -fdata-sections -Wl,--gc-sections`, and counted the setters with `nm`: + +| program | options | setters linked | text (B) | +|---|---|---|---| +| one member through the struct | `-Os` | 6 of 6 | 4,515 | +| the same, `apply` marked `[[gnu::always_inline]]` | `-Os` | 1 | 4,212 | +| one member by name | `-Os` | 1 | 4,212 | +| each of the three | `-O2` | 1 | 4,212 | + +With one call site and a constant struct, inlining lets GCC see which members are empty and drop their branches. At `-Os` it does not inline a function that size, so the linker sees six live calls. I measured one call site only. A program with many call sites would copy a forced-inline `apply` into each before the branches fold. + +## What it cost in lvgl26 + +lvgl26 has both forms. `dial.set({.value = v})` takes an aggregate with one member for each property of the widget, built by reflection. Its [apply function](https://github.com/filipsajdak/lvgl26/blob/3a23a478ca2593d4d6517e8d7854f6a4ae72cb15/include/lv/props.hpp#L1089-L1106) tests each member in a `template for` loop. The arc widget's instance alone is 6,298 B, and it stays a function of its own at `-Os`. + +The [research note](https://github.com/filipsajdak/lvgl26/blob/3a23a478ca2593d4d6517e8d7854f6a4ae72cb15/docs/research/size-vs-c.md) measured the change of one line in its Cortex-M4 test program, on 28 November with GCC 16.2 at `-Os`: + +| the task's line | flash (B) | RAM, data (B) | +|---|---|---| +| `dial.set({.value = v})` | 283,724 | 4,224 | +| `dial.set<"value">(v)` | 249,700 | 624 | + +The note splits the 34,024 B in two parts. 262 symbols took 15,222 B, among them the arc's apply function and 2,788 B of local style setters. Contract records and their strings took 18,759 B in the program's own object. 98 of its 112 checks came from two contract assertions in the bind path, instantiated once for each member of the struct. Under GCC 16.2's default `enforce` semantic each check stores a record in a writable section. That is where the 3,600 B of RAM went. + +lvgl26 now ships contracts as `quick_enforce` and links `std::terminate` to newlib's abort function. With those settings the same note measured the struct form at 15,392 B more flash than the name. The RAM difference was zero. + +## Several names at once + +One name covers one property. [Pull request 303](https://github.com/filipsajdak/lvgl26/pull/303) added a list: `dial.set<"value", "range">(v, {0, 240})`. Each value has the type of the member of that name, an unknown name is a compile error, and only the named setters are linked. The PR measured that line at 249,392 B of text, on its own base. That is 256 B above the single name and 30,568 B of text below the struct form. + +[Pull request 307](https://github.com/filipsajdak/lvgl26/pull/307) fixed the next cost. A tree of widgets now calls the setter of a constant property inline with its value, as C does with `lv_arc_set_value(dial, 120)`. Over 0 to 16 extra label and arc pairs, the PR measured 223.5 B of text per pair before and 87.75 B after. + +The [measurements of 29 November](https://github.com/wrocpp/cpp26-reflection-examples/tree/96d26715a4e45da052e63b74c56a14fb51db81b0/posts/152-where-did-my-flash-go/RESULTS.md) repeat the program at lvgl26 commit `3a23a478`, with all six size fixes merged. A pair now takes 68.3 B of flash against 57.3 B in plain C. That slope is text plus data, from 4 to 16 pairs, so it differs from the PR's text-only figure. The whole program is 2,528 B above the same screen in C: on flash lvgl26 matches C and does not beat it. On heap a pair takes 453 B against 468 B in C as usually written, and 456 B in C with static texts. + +The examples, with the link commands and every output, are in [`posts/151-options-struct-links-every-setter`](https://github.com/wrocpp/cpp26-reflection-examples/tree/b328aa5896f5463694d43183353f7bcc6ffafcaa/posts/151-options-struct-links-every-setter). The Compiler Explorer runs and the local links ran on 29 November 2026. The LTO crash was the other size fix of the same week. Designated initializers remain the way I build a value; this post is about the function that reads one.