ac-library icon indicating copy to clipboard operation
ac-library copied to clipboard

expander.py: trace line numbers back to the original source file

Open ssvb opened this issue 1 year ago • 0 comments

Using the "#line" directives, it's possible to allow compilers to report line numbers from the original source file. At least GCC and Clang support this. It's useful for tracing the compilation error locations back to the original file. Example:

  #include <iostream>
  #include <atcoder/lazysegtree>
  int main() {
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(arr);
  }

== The current default behaviour: ==

$ ./expander.py example.cpp
$ g++ combined.cpp
combined.cpp: In function ‘int main()’:
combined.cpp:263:3: error: ‘lazy_segtree’ was not declared in this
                    scope; did you mean ‘atcoder::lazy_segtree’?

== With the new '--origname' option: ==

$ ./expander.py --origname=example.cpp example.cpp
$ g++ combined.cpp
example.cpp: In function ‘int main()’:
example.cpp:4:3: error: ‘lazy_segtree’ was not declared in this
                 scope; did you mean ‘atcoder::lazy_segtree’?

ssvb avatar Dec 14 '23 00:12 ssvb