You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
halcompile: warn about, and reject colliding, mangled HAL names
A name declared in a .comp file is a C identifier, but it is exported
under a mangled HAL identifier: underscores become dashes and a trailing
dash or period is removed (comp.adoc, HALNAME). Nothing said so at
compile time, so "pin in float my_input" silently became
component.N.my-input.
Worse, check_name_ok() compares only declared names. Two declarations
that mangle to the same HAL name -- x_y and x_y_, the two rows of the
HALNAME table that share a HAL identifier -- therefore compiled cleanly
and failed much later, at load time:
HAL: ERROR: duplicate variable 'collide.0.x-y'
collide: rtapi_app_main: Invalid argument (-22)
Add check_hal_name(), which rejects that collision at the offending
line, and a once-per-file warning listing the names whose HAL identifier
differs from the declaration. Both messages point at the HALNAME
documentation. The warning is suppressed by -N (--no-name-warnings),
which the in-tree component rules pass, since those names are deliberate.
All 119 in-tree .comp files preprocess with no new error, and silently
under -N. tests/halcompile/halname covers the warning, -N, and the
rejected collision.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/man/man1/halcompile.1
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,14 @@ Install \fB.c\fR and \fB.py\fR files into the proper directory for HAL non-realt
76
76
Extract documentation from \fB.comp\fR files into \fB.9\fR manpage files in the proper system directory (the \fB\-\-install\fR flag), which may require \fIsudo\fR to write to system directories.
77
77
.IP\(bu4
78
78
Preprocess \fB.comp\fR files into \fB.c\fR files (the \fB\-\-preprocess\fR flag)
79
+
.SH NAMES
80
+
A name declared in a \fB.comp\fR file is a C identifier, but it is exported under a mangled HAL identifier: underscores become dashes, and a trailing dash or period is removed.
81
+
A pin declared \fBpininfloatmy_input\fR is therefore reached from HAL as \fBcomponent.N.my\-input\fR, not \fBcomponent.N.my_input\fR, and a component loaded with \fBloadrtmy_comp\fR exports its pins under \fBmy\-comp.N.\fR
82
+
.PP
83
+
\fBhalcompile\fR prints one warning per file listing the names this applies to; pass \fB\-N\fR (\fB\-\-no\-name\-warnings\fR) to suppress it.
84
+
Two declarations that mangle to the same HAL name (for example \fBx_y\fR and \fBx_y_\fR) are rejected, since they would otherwise be accepted here and fail later at \fBloadrt\fR with "HAL: ERROR: duplicate variable".
85
+
.PP
86
+
See HALNAME under \fISyntax\fR in the \fIHalcompileHALComponentGenerator\fR documentation for the full mangling rules.
79
87
.SH "SEE ALSO"
80
88
\fIHalcompileHALComponentGenerator\fR in the LinuxCNC documentation for a full description of the \fB.comp\fR syntax, along with examples
halname_mangled.comp:0: Warning: 1 declared name(s) are exported under a different HAL name: my_pin -> my-pin. Use the HAL name in HAL files, halcmd and halshow; see HALNAME under 'Syntax' in the Halcompile HAL Component Generator documentation, https://linuxcnc.org/docs/html/hal/comp.html
2
+
halname_collision.comp:4:18: 'x_y' and 'x_y_' both export the HAL name 'x-y'; see HALNAME under 'Syntax' in the Halcompile HAL Component Generator documentation, https://linuxcnc.org/docs/html/hal/comp.html
0 commit comments