Assumes the package name is foo and the message is a subdirectory named msg.
Expected behavior
Code is successfully generated and compiled for the message type.
Actual behavior
The constant UNSIGNED_LONG_CONSTANT is not resolved correctly. In cases (1) and (2), we get the following compilation error:
In file included from /tmp/bug_report/build/foo/rosidl_generator_c/foo/msg/detail/my_message__functions.h:19,
from /tmp/bug_report/build/foo/rosidl_generator_c/foo/msg/detail/my_message__functions.c:4:
/tmp/bug_report/build/foo/rosidl_generator_c/foo/msg/detail/my_message__struct.h:34:74: error: ‘UNSIGNED_LONG_CONSTANT’ undeclared here (not in a function)
34 | foo__msg__MyMessage__constant_bounded_wstring_value__MAX_STRING_SIZE = UNSIGNED_LONG_CONSTANT
| ^~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/foo__rosidl_generator_c.dir/build.make:92: CMakeFiles/foo__rosidl_generator_c.dir/rosidl_generator_c/foo/msg/detail/my_message__functions.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:301: CMakeFiles/foo__rosidl_generator_c.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
TypeError in template '/home/jacob/ws/ros/latest/install/rosidl_typesupport_introspection_cpp/share/rosidl_typesupport_introspection_cpp/resource/msg__type_support.cpp.em': %u format: a number is required, not str
TypeError when expanding 'idl__type_support.cpp.em' into '/tmp/bug_report/build/foo/rosidl_typesupport_introspection_cpp/foo/msg/detail/my_message__type_support.cpp': %u format: a number is required, not str
Error processing idl file: /tmp/bug_report/src/foo/msg/MyMessage.idl
Traceback (most recent call last):
File "/home/jacob/ws/ros/latest/install/rosidl_typesupport_introspection_cpp/lib/rosidl_typesupport_introspection_cpp/rosidl_typesupport_introspection_cpp", line 23, in <module>
sys.exit(main())
File "/home/jacob/ws/ros/latest/install/rosidl_typesupport_introspection_cpp/lib/rosidl_typesupport_introspection_cpp/rosidl_typesupport_introspection_cpp", line 19, in main
return generate_cpp(args.generator_arguments_file)
File "/home/jacob/ws/ros/latest/install/rosidl_typesupport_introspection_cpp/lib/python3.8/site-packages/rosidl_typesupport_introspection_cpp/__init__.py", line 24, in generate_cpp
generate_files(generator_arguments_file, mapping)
File "/home/jacob/ws/ros/latest/install/rosidl_cmake/lib/python3.8/site-packages/rosidl_cmake/__init__.py", line 96, in generate_files
raise(e)
File "/home/jacob/ws/ros/latest/install/rosidl_cmake/lib/python3.8/site-packages/rosidl_cmake/__init__.py", line 87, in generate_files
expand_template(
File "/home/jacob/ws/ros/latest/install/rosidl_cmake/lib/python3.8/site-packages/rosidl_cmake/__init__.py", line 149, in expand_template
interpreter.string(template_content, template_path, locals=data)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2391, in string
self.safe(scanner, True, locals)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2401, in safe
self.parse(scanner, locals)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2421, in parse
token.run(self, locals)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 1547, in run
self.subrun(info[0][1], interpreter, locals)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 1631, in subrun
token.run(interpreter, locals)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 1425, in run
interpreter.execute(self.code, locals)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2596, in execute
_exec(statements, self.globals, locals)
File "<string>", line 2, in <module>
File "/home/jacob/ws/ros/latest/install/rosidl_cmake/lib/python3.8/site-packages/rosidl_cmake/__init__.py", line 198, in _expand_template
interpreter.string(content, str(template_path), kwargs)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2391, in string
self.safe(scanner, True, locals)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2401, in safe
self.parse(scanner, locals)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2421, in parse
token.run(self, locals)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 1425, in run
interpreter.execute(self.code, locals)
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2596, in execute
_exec(statements, self.globals, locals)
File "<string>", line 27, in <module>
TypeError: %u format: a number is required, not str
Exception ignored in: <function Interpreter.__del__ at 0x7f8a84dcee50>
Traceback (most recent call last):
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2094, in __del__
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2157, in shutdown
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2647, in finalize
File "/home/jacob/.local/lib/python3.8/site-packages/em.py", line 2200, in push
AttributeError: '_io.TextIOWrapper' object has no attribute 'push'
make[2]: *** [CMakeFiles/foo__rosidl_typesupport_introspection_cpp.dir/build.make:70: rosidl_typesupport_introspection_cpp/foo/msg/detail/my_message__rosidl_typesupport_introspection_cpp.hpp] Error 1
make[2]: *** Deleting file 'rosidl_typesupport_introspection_cpp/foo/msg/detail/my_message__rosidl_typesupport_introspection_cpp.hpp'
make[1]: *** [CMakeFiles/Makefile2:468: CMakeFiles/foo__rosidl_typesupport_introspection_cpp.dir/all] Error 2
In case (3), we get a different error:
'>' not supported between instances of 'str' and 'int' /tmp/bug_report/src/foo/msg/MyMessage.idl
Error processing idl file: /tmp/bug_report/src/foo/msg/MyMessage.idl
'>' not supported between instances of 'str' and 'int' /tmp/bug_report/src/foo/msg/MyMessage.idl
Error processing idl file: /tmp/bug_report/src/foo/msg/MyMessage.idl
Traceback (most recent call last):
File "/home/jacob/ws/ros/latest/install/rosidl_generator_c/share/rosidl_generator_c/cmake/../../../lib/rosidl_generator_c/rosidl_generator_c", line 40, in <module>
sys.exit(main())
File "/home/jacob/ws/ros/latest/install/rosidl_generator_c/share/rosidl_generator_c/cmake/../../../lib/rosidl_generator_c/rosidl_generator_c", line 34, in main
return generate_c(
File "/home/jacob/ws/ros/latest/install/rosidl_generator_c/lib/python3.8/site-packages/rosidl_generator_c/__init__.py", line 37, in generate_c
generate_files(
File "/home/jacob/ws/ros/latest/install/rosidl_cmake/lib/python3.8/site-packages/rosidl_cmake/__init__.py", line 96, in generate_files
raise(e)
File "/home/jacob/ws/ros/latest/install/rosidl_cmake/lib/python3.8/site-packages/rosidl_cmake/__init__.py", line 74, in generate_files
idl_file = parse_idl_file(locator)
File "/home/jacob/ws/ros/latest/install/rosidl_parser/lib/python3.8/site-packages/rosidl_parser/parser.py", line 64, in parse_idl_file
content = parse_idl_string(string, png_file=png_file)
File "/home/jacob/ws/ros/latest/install/rosidl_parser/lib/python3.8/site-packages/rosidl_parser/parser.py", line 73, in parse_idl_string
content = extract_content_from_ast(tree)
File "/home/jacob/ws/ros/latest/install/rosidl_parser/lib/python3.8/site-packages/rosidl_parser/parser.py", line 144, in extract_content_from_ast
add_message_members(msg, struct_defs[0])
File "/home/jacob/ws/ros/latest/install/rosidl_parser/lib/python3.8/site-packages/rosidl_parser/parser.py", line 365, in add_message_members
abstract_type = get_abstract_type_from_type_spec(type_spec)
File "/home/jacob/ws/ros/latest/install/rosidl_parser/lib/python3.8/site-packages/rosidl_parser/parser.py", line 406, in get_abstract_type_from_type_spec
return get_abstract_type(child)
File "/home/jacob/ws/ros/latest/install/rosidl_parser/lib/python3.8/site-packages/rosidl_parser/parser.py", line 456, in get_abstract_type
assert maximum_size > 0
TypeError: '>' not supported between instances of 'str' and 'int'
make[2]: *** [CMakeFiles/foo__rosidl_generator_c.dir/build.make:75: rosidl_generator_c/foo/msg/my_message.h] Error 1
make[1]: *** [CMakeFiles/Makefile2:300: CMakeFiles/foo__rosidl_generator_c.dir/all] Error 2
Additional information
I haven't tried, but I assume the issue relates to all types of constants, not just unsigned longs.
Bug report
Required Info:
Steps to reproduce issue
Try to build the following message defined with IDL:
Assumes the package name is
foo
and the message is a subdirectory namedmsg
.Expected behavior
Code is successfully generated and compiled for the message type.
Actual behavior
The constant
UNSIGNED_LONG_CONSTANT
is not resolved correctly. In cases (1) and (2), we get the following compilation error:In case (3), we get a different error:
Additional information
I haven't tried, but I assume the issue relates to all types of constants, not just unsigned longs.