Counting functions in C source code

后端 未结 6 929
隐瞒了意图╮
隐瞒了意图╮ 2021-01-19 08:17

I have complete project in C, which can be built with gcc or Visual Studio. There are no calls to external libraries.

I would like to know how many functions there

6条回答
  •  滥情空心
    2021-01-19 08:38

    With gcc:

    $ nm elf_file | grep "T " | grep -v " _" | wc -l
    

    Note that gcc can inline some functions even with optimizations disabled, so you should compile with:

    -O0 -fno-builtin -fno-inline-functions-called-once

    (-finline-functions-called-once is enabled by default even in -O0)

提交回复
热议问题