Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDL relative includes #1970

Open
jakubStefanisin opened this issue Apr 8, 2024 · 2 comments
Open

IDL relative includes #1970

jakubStefanisin opened this issue Apr 8, 2024 · 2 comments

Comments

@jakubStefanisin
Copy link

Getting weird behavior, Time.idl is found under std_msgs/msg but then generation breaks even if direct include to std_msgs/msg is provided. Seems like relative paths inside included IDL are not processed correctly.

File structure:

  • idl
    • geometry_msgs
      • msg
        • AccelStamped.idl
    • std_msgs
      • msg
        • Header.idl
        • Time.idl

AccelStamped.idl:

#include "Accel.idl"
#include <std_msgs/msg/Header.idl>

module geometry_msgs { module msg {

struct AccelStamped {
std_msgs::msg::Header header;
geometry_msgs::msg::Accel accel;
};

}; }; // module msg::geometry_msgs

Header .idl:

#include "Time.idl"

module std_msgs { module msg {

struct Header {
std_msgs::msg::Time stamp;
string frame_id;
};

}; }; // module msg::std_msgs

ERROR:

./idlc -I /home/xxx/src/interfaces/idl/std_msgs/msg -I /home/xxx/src/interfaces/idl /home/xxx/src/interfaces/idl/geometry_msgs/msg/AccelStamped.idl
Invalid line marker: path '/home/xxx/src/interfaces/idl/Time.idl' not found
/home/xxx/src/interfaces/idl/std_msgs/msg/Time.idl:20: fatal error: File write error
module std_msgs { module msg {
from /home/xxx/src/interfaces/idl/std_msgs/msg/Header.idl: 21: #include "Time.idl"
from /home/xxx/src/interfaces/idl/geometry_msgs/msg/AccelStamped.idl: 21: #include <std_msgs/msg/Header.idl>
1 error in preprocessor.

Is this expected behavior?

@uupks
Copy link

uupks commented Apr 11, 2024

If you want to use idlc to genereta source code for rosidl , you can try
How to use idlc to compile *.idl

@eboasson
Copy link
Contributor

This is a bug that I can reproduce without any difficulty, I looked at it for a few minutes and came up with a quick hack that seems to make it work, but it'll take me a bit more time to fix it properly:

diff --git a/src/idl/src/directive.c b/src/idl/src/directive.c
index bb24af39e..ad63afea0 100644
--- a/src/idl/src/directive.c
+++ b/src/idl/src/directive.c
@@ -149,10 +149,13 @@ static idl_retcode_t push_line(idl_pstate_t *pstate, struct line *dir)
 
     if ((ret = idl_normalize_path(dir->path, &norm)) < 0) {
       idl_error(pstate, NULL, "Invalid line marker: path '%s' not found", dir->path);
+#if 0
       return ret;
+#endif
+    } else {
+      idl_free(dir->path);
+      dir->path = norm;
     }
-    idl_free(dir->path);
-    dir->path = norm;
     assert(dir->file);
 
     if (idl_isabsolute(dir->file)) {

The idea of the hack is basically to treat it as a warning, rather than an error. It is relaly only about managing the include directory stack and the line markers, and so continuing seems the lesser of the evils.

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

No branches or pull requests

3 participants