Skip to content

Commit

Permalink
Use deterministic iteration in type_support header
Browse files Browse the repository at this point in the history
The `include_directives` set is used by the nested templates to
prevent generation of duplicate include directives, but is not iterated
over by those nested templates.

In `idl__type_support.c.em` rather that iterating over the
`include_directives` set (which introduces non-determinism) to generate
the includes for top level header files, we iterate over those top level
includes as a list and seperately construct the `include_directives` set
from the list. This ensures deterministic codegen.

Signed-off-by: Harry Sarson <harry.sarson@codethink.co.uk>
  • Loading branch information
harrysarson committed Dec 5, 2024
1 parent 40a591c commit a9ea6b0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rosidl_generator_c/resource/idl__type_support.c.em
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ include_parts = [package_name] + list(interface_path.parents[0].parts) + [
'detail', convert_camel_case_to_lower_case_underscore(interface_path.stem)]
include_base = '/'.join(include_parts)

include_directives = {
top_level_includes = [
'rosidl_typesupport_interface/macros.h',
include_base + '__type_support.h',
include_base + '__struct.h',
include_base + '__functions.h'}
include_base + '__functions.h']

include_directives = set(top_level_includes)

}@

#include <string.h>

@[for header_file in include_directives]@
@[for header_file in top_level_includes]@
#include "@(header_file)"
@[end for]@

Expand Down

0 comments on commit a9ea6b0

Please sign in to comment.