Re:Tell HN: C Experts Panel – Ask us anything about C
by sgawlik on Tuesday April 14, 2020 @09:36AM
(#22865744)
When you're looking at an unfamiliar C code base for the first time, how do you approach it? Which files do you look for? Which tools to you open up immediately?
[ Parent
| on HN ]
Re:Tell HN: C Experts Panel – Ask us anything about C
by rseacord on Tuesday April 14, 2020 @10:57AM
(#22866786)
This depends a bunch on what your goals are. There are no specially named files, so looking for a particular filename is not particularly useful. It is sometimes informative to find the file containing the main, but not always.
My job at NCC Group involves a lot of code reviews, so frequently the files that are of interest to me are the ones that contain the most defects. I typically identify these by compiling with compiler warnings turned up and warning suppression turned down. I'll frequently also make use of static and dynamic analysis, including the GCC and Clang sanitizers.
Re:Tell HN: C Experts Panel – Ask us anything about C
by DougGwyn on Tuesday April 14, 2020 @09:48AM
(#22865892)
It all depends on how organized previous workers were, and what your goal is for a modification of the source text. Often, headers (dot-h files) document the data structures and interfaces.
Re:Tell HN: C Experts Panel – Ask us anything about C
by loeg on Tuesday April 14, 2020 @12:11PM
(#22867709)
I start with generating tags.
exctags --exclude=TAGS --exclude=TAGS.NEW --append -R -f TAGS.NEW --sort=yes && mv TAGS.NEW TAGS
My editor (vim) has native support for quickly jumping from a use to definition via this TAGS index. History is preserved (i.e., there is a "back" button), so you can quickly dive through 5 layers of API and back out to understand where a value went. It is quite useful for starting with what you know and following it to the surprising behavior, without executing the code.
Re:Tell HN: C Experts Panel – Ask us anything about C
by jhallenworld on Tuesday April 14, 2020 @10:06AM
(#22866124)
cscope can help
Re:Tell HN: C Experts Panel – Ask us anything about C
by clarry on Tuesday April 14, 2020 @04:42PM
(#22871172)
Is there a vim-style cscope interface for emacs? I hate that xcscope brings up its own persistent buffers (replacing other buffers that I had deliberately placed on the screen). Vim, conveniently, just pops up the cscope interface when I need to enter some input, and then hides it away. Also I don't think xcscope works with evil's tag stack whereas in vim, I believe, you can just return to where you were with ^T, whether using ctags or cscope.