Skip to content

Commit

Permalink
Allow to run clang-format on nocmodl generated C++ files (#2542)
Browse files Browse the repository at this point in the history
With the current master if we run clang-format on generated file
and try to rebuild then we get errors like

```
src/nrnoc/netstim.cpp:393:28: error: no member named '_prop' in 'Point_process'; did you mean 'prop'?
    auto* const _p = _pnt->_prop;
```

This is because we have some magic header macros that rename certain
internal variables.

To avoid the issue, just tell clang-format to avoid sorting headers
included.
  • Loading branch information
pramodk authored Sep 27, 2023
1 parent ecb0999 commit 8985d2b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/nmodl/noccout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ void c_out() {
P("#undef PI\n");
P("#define nil 0\n");
P("#define _pval pval\n"); // due to some old models using _pval
P("// clang-format on\n");
P("#include \"md1redef.h\"\n");
P("#include \"section_fwd.hpp\"\n");
P("#include \"nrniv_mf.h\"\n");
P("#include \"md2redef.h\"\n");
P("// clang-format off\n");
P("#include \"neuron/cache/mechanism_range.hpp\"\n");
P("#include <vector>\n");

Expand Down Expand Up @@ -481,10 +483,12 @@ void c_out_vectorize() {
P("#undef PI\n");
P("#define nil 0\n");
P("#define _pval pval\n"); // due to some old models using _pval
P("// clang-format off\n");
P("#include \"md1redef.h\"\n");
P("#include \"section_fwd.hpp\"\n");
P("#include \"nrniv_mf.h\"\n");
P("#include \"md2redef.h\"\n");
P("// clang-format on\n");
P("#include \"neuron/cache/mechanism_range.hpp\"\n");
printlist(defs_list);
printlist(firstlist);
Expand Down

0 comments on commit 8985d2b

Please sign in to comment.