Skip to content

fix: Arduino-IDE prototypes, INPUT_PULLUP, and documented simulator limits - #252

Merged
ttbombadil merged 3 commits into
mainfrom
fix/sketch-prototypes-and-pullup
Oct 18, 2026
Merged

ttbombadil merged 3 commits into
mainfrom
fix/sketch-prototypes-and-pullup

Conversation

@ttbombadil

Copy link
Copy Markdown
Collaborator

Summary

  • Prototypes like the Arduino IDE. Generated function prototypes now sit directly before the first function the sketch defines (after inlined headers) and omit default arguments. Before, they stood at the top of the file, so sketches with typedef types in signatures (Vektor add(Vektor, Vektor)), constant array sizes (void f(double m[M][N])) or default arguments compiled with arduino-cli but failed in the local g++ build. These patterns appear in the course slides IT08 and IT11.
  • INPUT_PULLUP reads HIGH. pinMode(pin, INPUT_PULLUP) drives the simulated pin HIGH and reports it to the board view; before, an open input read LOW as if a button were pressed. The board toggle derives the new value from the reported state, so clicking still toggles to LOW.
  • Docs. The user guide gets a section "Grenzen der Simulation" listing the remaining differences to a real Uno (32-bit int, 64-bit long/double, sizeof, float printing without precision, parseInt without timeout, loop speed, memory, random()); CHANGELOG entries for both fixes.

Tests

  • Unit: new sketch-prototypes.test.ts and builder cases (typedef, array constants, default arguments, header). Two existing builder tests changed their position assertion from "before the user-code marker" to "before the first function definition" (approved by the maintainer).
  • Integration (toolchain): new sketch-runtime-fidelity.test.ts builds and runs real sketches with g++ (pull-up, typedef signature, header with constant sizes and defaults).
  • Local ./run-tests.sh: all steps green (unit 3103, toolchain 17, Docker 32, E2E 28, production build, audit). SonarQube was not available locally.
  • All 51 examples of feat(examples): rebuild the catalog along the course weeks ttbombadil/UnoSim-Examples#10 and the 35 previous examples compile with the new builder.

Note

The E2E test 03_compiler_cli_success_context expects English arduino-cli output. With an empty LANG on a German macOS, arduino-cli answers in German and the test fails; the result is also cached in storage/cache. Not changed here.

🤖 Generated with Claude Code

ttbombadil and others added 3 commits October 18, 2026 10:06
The local build put every generated prototype at the top of the file. A
prototype whose signature uses a typedef or a constant (Vektor add(Vektor,
Vektor), void f(double m[M][N])) then failed, and a function with default
arguments failed with "redefinition of default argument", although the
Arduino compiler accepted the sketch.

Prototypes now go directly before the first function the sketch itself
defines (after inlined headers) and leave out default arguments. Comments are
masked with the existing offset-preserving helper.

The two builder tests that required the prototypes above the user-code marker
now require them before the first function definition (approved by the user).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pinMode(pin, INPUT_PULLUP) now drives the simulated pin HIGH, as the internal
pull-up resistor of the Uno does, and reports the value to the board view.
Before, an open input read LOW as if a button were pressed.

A toolchain integration test runs real sketches through the builder and g++
and covers the pull-up, a typedef signature, and a header with constant array
sizes and default arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The user guide gets a section "Grenzen der Simulation" for students and
teachers: int and unsigned int are 32 bits, long and double 64 bits, sizeof,
float printing without precision, parseInt without timeout, loop speed,
memory size and random(). The changelog notes both fixes and points operators
to the section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ttttttom

Copy link
Copy Markdown

fine

@ttbombadil
ttbombadil merged commit 5994721 into main Oct 18, 2026
6 checks passed
@ttbombadil
ttbombadil deleted the fix/sketch-prototypes-and-pullup branch October 18, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants