Skip to content

classicladder: give the headers include guards and their own dependencies - #4430

Open
grandixximo wants to merge 1 commit into
LinuxCNC:masterfrom
grandixximo:classicladder-headers
Open

classicladder: give the headers include guards and their own dependencies#4430
grandixximo wants to merge 1 commit into
LinuxCNC:masterfrom
grandixximo:classicladder-headers

Conversation

@grandixximo

Copy link
Copy Markdown
Contributor

30 of the 34 headers in hal/classicladder have no include guard, and 12 do not compile on their own. They name StrRung, StrStep, cairo_t or the gtk types without including whatever declares them, and build only because the file that included them had already got there.

Guards go in first, since including classicladder.h from twelve places without them redefines everything. Then the twelve name what they use.

The guards are CLASSICLADDER_<FILE>_H. The four that had one already used a leading underscore, which is reserved to the implementation, so they are renamed rather than left as a second convention in one directory.

Testing. All 34 compile standalone afterwards, one translation unit per header, where 22 did before. Built clean with --with-realtime=uspace, no errors and no warnings.

Is it worth having? @BsAtHome this is your point from #4425, that a header needing something should be the one to say so, applied to a subsystem you did not ask about. classicladder is old code nobody is working on, so if 34 files of churn reads as noise, say so and I will close it.

Independent of #4425, overlapping by one line, the <stdio.h> in files.h.

…cies

30 of the 34 headers in hal/classicladder have no include guard, and 12 do
not compile on their own.  They name StrRung, StrSection, StrSymbol, StrStep,
cairo_t or the gtk types without including whatever declares them, and build
only because the file that included them had already got there.

Guards go in first, since including classicladder.h from twelve places
without them redefines everything.  Then the twelve name what they use:
classicladder.h for the ladder types, sequential.h for StrStep and
StrTransition in drawing_sequential.h, <gtk/gtk.h> for the five _gtk headers,
<cairo.h> and <stddef.h> for drawing.h, and <stdio.h> for the FILE * in
files.h.

The guards are named CLASSICLADDER_<FILE>_H.  The four headers here that had
one already used a leading underscore, which is reserved to the
implementation, so they are renamed to match rather than left as a second
convention in the same directory.  Plain uppercase with no underscore is what
most of the tree uses; the prefix is because names like FILES_H, CALC_H and
GLOBAL_H are too general to leave unqualified.

All 34 compile standalone afterwards, one translation unit per header against
the userspace include path, where 22 did before.  Full build clean, no errors
and no warnings.

The stdio.h line in files.h is also in LinuxCNC#4425, which reaches it from the other
direction; the two overlap by that one line and nothing else.
@rmu75

rmu75 commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Adding to the noise: is there a reason not to use #pragma once? While not in any C/C++ standard it is probably even rarer for a compiler to not support that than non-two's complement int representation.

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