Generated Header with Dolfin backend Include Guards are mangled when input file is in a different directory

Issue #42 resolved
Andrey Shmakov created an issue

FFC places standard CPP include guards in generated header files for use with Dolfin. However when ffc is invoked with ffc path/to/other/dir/file.ufl the ffc includes preproccessor illegal tokens (forward slashes) in the define guard. Causing compilation failure. Furthermore, because filename is split with filename.split(.)[0] in the ffc script. Relative paths like ../relative/path/to/dir/file.ufl result in a include guard that is identical between all relative files __h

FIX: Given in pull request

  1. use os.splitext to split filename
  2. use regexp to replace all invalid characters with __ to preserve path/filename differentiation

Comments (10)

  1. Martin Sandve Alnæs

    Thanks for the report and patch. Is path differentiation necessary? Would just using the basename be sufficient? I think you can set the prefix on the commandline as well.

  2. Andrey Shmakov reporter

    Probably not, there may be edge cases where it is an issue, I can push a second fix tomorrow if you like , time to go home :)

  3. Martin Sandve Alnæs

    Since we haven't heard from Andrey Shmakov and I needed this I've fixed it in martinal/fix-ufl-file-path-bug and pushed to next. I fixed it only in scripts/ffc, also handles validating the prefix such that ../blatti/foo.bar.ufl gets a valid prefix foo_bar.

  4. Log in to comment