-
Notifications
You must be signed in to change notification settings - Fork 63
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
Cannot use after delay with user-defined types #1958
Comments
Our options are:
The advantage of option 1 is that it closes this issue and eliminates one pitfall that users might run into. It is a simple solution that is very likely to fully fix this problem. The advantage of option 2 is that it places responsibility on the user to understand how the |
I prefer option 1. Option 2 will also require specifying the included header file in the target files directive, adding complication. Also, rather the a separate header file, a more elegant way to share declarations across reactor definitions in separate files is inheritance. Note that we often get name collisions anyway. I find that usually need to guard everything in a file-level preamble with
If we remove the |
The files directive may need to be used in many nontrivial programs. Furthermore, in my experience it is common for some set of type definitions to be used in several places throughout a program. In this case, it is not obvious to me that having every reactor in a program inherit from the reactor that carries the typedefs is the most elegant way to share declarations.
This sounds like a mistake on my part because we should be automatically wrapping those in an include guard named Anyway, it will be no problem for me to implement option 1. I will do that today. |
I am lacking some understanding about the implementation of C preambles here, but it seems like the C++ implementation could serve as a good template. After all preambles in conjunction with modular code generation have been working and tested for some years now.
I find this strange. Why not guard the preamble automatically in the code generator? In the C++ target, every public preamble becomes a header file and the include guards are added automatically. There is also no hashing needed, as they can be named uniquely within one program. Making a preamble visible, then means that the corresponding header gets included. This can be done completely automatically. |
As I said, that is what we do. It would be helpful to have a minimal reproduction that shows why our mechanism does not work.
I'm not sure what this means. The purpose of hashing is to provide a unique name to include guard. Also, hashing is just an implementation detail that the user does not usually need to worry about, so although I'm sure there are other ways to do this, I am not sure what would be wrong with the current approach. |
1 similar comment
As I said, that is what we do. It would be helpful to have a minimal reproduction that shows why our mechanism does not work.
I'm not sure what this means. The purpose of hashing is to provide a unique name to include guard. Also, hashing is just an implementation detail that the user does not usually need to worry about, so although I'm sure there are other ways to do this, I am not sure what would be wrong with the current approach. |
An example that fails to compile without manually guarding the preamble can be found in the leader-election branch of the playground-lingua-franca repo. The file is examples/C/src/leader-election/NRP_FD.lf. If you remove the guard in the preamble, then lfc reports this:
Sorry, I don't have a more minimal example. |
If you use a typedef to define type and import a file with the type defined in a file-scoped preamble, the type is not made available to the generated delay reactors. This makes it very difficult (impossible?) to use after delays with user-defined types unless everything is one file.
To reproduce, put the following into a file
GenDelay.lf
:Then put this into another file, e.g.
GenDelayTest.lf
:The file fails to compile with this error:
The text was updated successfully, but these errors were encountered: