Docs: AGENTS.template.md says standard headers are never #included, and five library units and twelve tests include C and POSIX headers #207
Labels
No labels
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Crafter.Graphics#207
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The guide's code style says "
import std;everywhere. Standard headers are never#included; [...] Tests may#include <cstdlib>,<cstring>or<cstddef>for the macrosimport std;does not provide." (AGENTS.template.md:97at148ed01). The code does otherwise, in files older than #167's fix as well: C and POSIX headers are included wherever a unit needserrno,stdout,mmap,poll, a socket or a child process, whichimport std;does not provide.Details
At
148ed01:interfaces/Crafter.Graphics-Window.cppm(<stdio.h>,<stdlib.h>,<unistd.h>,<string.h>,<sys/mman.h>,<errno.h>,<fcntl.h>);implementations/Crafter.Graphics-Window.cpp(the same, and<sys/stat.h>,<time.h>,<poll.h>);implementations/Crafter.Graphics-Device.cpp(<string.h>,<stdio.h>,<stdlib.h>,<errno.h>,<unistd.h>,<sys/mman.h>);implementations/Crafter.Graphics-Clipboard.cpp(<unistd.h>,<errno.h>,<poll.h>,<fcntl.h>);implementations/Crafter.Graphics-Gamepad.cpp(<fcntl.h>,<unistd.h>,<poll.h>,<sys/ioctl.h>).<sys/socket.h>,<unistd.h>,<cerrno>); DebugMessengerSeverity (<cstdio>,<unistd.h>); DeviceSelection (<sys/wait.h>,<unistd.h>); HeapASRead and HeapDynamicIndexHit (<cstdio>); KeyboardKeymap (<cerrno>,<cstdio>,<fcntl.h>,<sys/mman.h>,<sys/wait.h>,<unistd.h>,<malloc.h>); ResizeViewport (<fcntl.h>,<unistd.h>,<cstdio>); VulkanBufferResizeReuse (<cstdint>); WindowUpdateClock (<cstdio>,<sys/eventfd.h>,<unistd.h>).Found in the pre-push review of #167's fix, whose
<errno.h>inDevice.cppand the headers of its new test are among these.Suggested fix
Write down the rule the code keeps: C++ standard headers are never included (
import std;); C and POSIX headers go in the global module fragment, behind the backend's#ifdef, where a unit needs a macro or a system call thatimport std;does not provide (errno,stdout,mmap,poll); tests include them as they need them.e1ca2fd(#169) adds two tests to the list: WindowConstructorThrow (<cstdio>,<dlfcn.h>,<fcntl.h>,<unistd.h>) and WindowConstructorThrowWin32 (<cstdio>, for thestdoutitsCheckflushes).