Closed cgmb closed 6 years ago
It's also a little annoying if you want a blank line between the last line of code and the #endif
. Not sure if it's better to correct that with a separate flag or just let you specify newlines in the template.
The behaviour in my previous comment seems to come from once2guard just appending the #endif
to the file, oblivious to whether the file ends in blank line or not. Trying to make a template language that allows you to conditionally decide to add newlines or not seems rather complicated both for users and for me. Perhaps that's best as just a separate flag.
Many projects include a comment after each
#endif
to specify what conditional is ending. It would be nice if you could specify how once2guard did this. For example, from node:A major part of why I built guardonce was to make it easy to convert back from #pragma once if a problem ever arises. If the generated code breaks a style guide and needs manual correction, that's a problem. once2guard and guard2once should be able to round-trip most guard styles.
There are lots of different styles, so perhaps the easiest thing to do would be to allow the user to provide a template. There just needs to be some way to refer to the generated guard symbol from that template.
It would work something like,
Fancier template languages like jinja seem a bit overkill, so perhaps a single special character to refer to the guard symbol would be sufficient. Or maybe I should use
{}
to matchfind
and friends?