-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add header files to examples and rename main.c #5
Comments
Sure. I like that the examples engender best practices. It seems such a shame to spend so much effort to make them so thorough and thoroughly neat/uniform/explicit and yet have these glaring imperfections. 🤷 So: I'll try list a few options my mind conjures up: I like It feels a pain to have to get extra nitpicky in the examples (-I for the .h), but again, it'll really round off the efforts. |
I like Shall we go with If we expand examples that currently have a single C file to be 4, we should consider calling GCC explicitly before GHDL, in order to merge all the C sources in a single object file. Then, GHDL would only need to pick that one. In fact, this is interesting because it shows when it is recommended to call GCC explicitly.
I think that code sources of examples should engender best practices, so that anyone who copies that only, gets a good working solution. Nevertheless, for completeness, we can (and should) explain other options in the docs, which users might find when they search for GHDL examples in the wild.
I believe that |
I only see at most 3 files needed?
|
@RocketRoss, see ghdl/ghdl@8346c71. Shall we use |
Darn... How did you even catch that find from Monsieur TGingold 👀 I like |
As @RocketRoss commented in umarcor#3 (comment) (see also umarcor#4 (comment)):
Currently, all of the examples in this repo use a single C source named
main.c
to contain all the required C resources (prototypes, definitions, types, etc.). This is done for simplicity, to ensure that including using a single additional file is enough. Precisely, the location of the header might need to be specified with-I
(as in https://github.com/umarcor/ghdl-cosim/blob/header/vhpidirect/cinterface/demo/run.sh#L11).Nonetheless, as @RocketRoss pointed out, this is not desirable from C language's point of view. On the one hand, files that do not contain a
main
should not be namedmain.c
. Which filename should we use instead?user
?helpers
?vhpidirect
? On the other hand, headers should be provided, which should include prototypes but not definitions.We should explain in one of the most simple examples that writing everything in a single file is technically possible, but not good coding practice.
The text was updated successfully, but these errors were encountered: