Skip to content

Add header files to examples and rename main.c #5

@umarcor

Description

@umarcor

As @RocketRoss commented in umarcor#3 (comment) (see also umarcor#4 (comment)):

Split ghdl.h > ghdl.h + ghdl.c

I think this point may be a bone of contention, but I also think that software people get quite concerned when they see function definitions in header files.

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 named main.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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions