Skip to content

Declare loop indexes in the for statement - #29

Merged
LarryRuane merged 1 commit into
masterfrom
for-decl
Oct 19, 2026
Merged

LarryRuane merged 1 commit into
masterfrom
for-decl

Conversation

@LarryRuane

Copy link
Copy Markdown
Owner

Moves loop index declarations into the for statement, for (int i = 0; ...), in plain (non-protothread) functions. That's three loops in protothread.h and most of the test file's setup and check loops. C99 allows it, and C99 is the oldest standard CI tests.

Protothread functions are left alone. A for-declared index there is still an ordinary local, lost across a block. Variables used outside their loops keep their declarations.

Based on #28, since it touches that PR's new tests. GitHub should retarget it to master once #28 is merged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs

C99 allows it, and C99 is the oldest standard CI tests. Only plain
functions are converted. In a protothread function a for-declared index
is an ordinary local, lost across a block, like any other.

Variables still used outside their loops keep their declarations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
Base automatically changed from timer-heap to master October 19, 2026 21:12
@LarryRuane
LarryRuane merged commit e02ea64 into master Oct 19, 2026
31 checks passed
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.

1 participant