yarp
yarp copied to clipboard
Include in thrift has unexpected behaviour
When using the include command in thrift the autogenerated files present some issues (I don't know if indented or not).
Let's exemplify the problem. I also attach a sample project which generates 3 thrift classes.
One class (BaseStruct) is in a separate file (Base.thrift)
struct BaseStruct {
1: double x;
2: double y;
}
The other two are defined in a separate thrift file (Full.thrift).
include "Base.thrift"
struct BaseInFullFile {
1: string var1;
2: double var2;
}
struct FullStruct {
1: Base.BaseStruct base;
2: double extended;
3: BaseInFullFile baseInFile;
}
Thrift generates one file per class.
If we examine the generated file for FullStruct we see the following includes:
#include <BaseStruct.h>
#include <thrift/BaseInFullFile.h>
Here we observe that the thrift struct defined in the same file is correctly included (note the `thrift prefix), while the one included in the thrift, is not.
This is somewhat related to this old issue: https://github.com/robotology/yarp/issues/487 (or if not, the old issue is not fully solved I think)
cc @drdanz @traversaro
This is not documented (or clear) on the original thrift page.
But en passant it is documented in http://www.yarp.it/thrift_tutorial.html. In particular
Included files are looked up in the current directory and by searching relative to the path from which the yarp_idl_to_dir macro is executed
If I understood correctly, adding include "Base.thrift" matches the current directory, i.e. it is able to find the include file, but of course the generated cpp file does not work.
On the contrary include "thrift/Base.thrift" will match the path relative to the yarp_idl_to_dir macro which works both when the thrift compiler is running and in the generated cpp.
@drdanz you can decide if this is the intended behaviour and close this issue or not
fyi @claudiofantacci
Looks like a bug to me...