gnu cflow 教學 (gnu cflow tutorial)

gnu cflow 教學與筆記。

Get started

Official manual webpage

Download source code

Official download webpage

1
2
wget https://ftp.gnu.org/gnu/cflow/cflow-latest.tar.gz
tar -xvf cflow-latest.tar.gz

Build source code

解壓縮後裡面有 INSTALL 文字檔案說明如何 build

1
2
3
4
cd <cflow folder>
./configure
make
sudo make install

使用方式

如果需要畫圖功能,還需要安裝 graphviz

1
sudo apt install graphviz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* whoami.c - a simple implementation of whoami utility */
#include <pwd.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>

int who_am_i(void) {
struct passwd *pw;
char *user = NULL;

pw = getpwuid(geteuid());
if(pw)
user = pw->pw_name;
else if((user = getenv("USER")) == NULL) {
fprintf(stderr, "I don't know!\n");
return 1;
}
printf("%s\n", user);
return 0;
}

int main(int argc, char **argv) {
if (argc > 1) {
fprintf(stderr, "usage: whoami\n");
return 1;
}
return who_am_i();
}
  • 產生 pdf 檔

    1
    cflow -f dot whoami.c | dot -Tpdf -o ~/Desktop/cflow_example.pdf
  • 結果圖
    cflow example

gnu cflow 教學 (gnu cflow tutorial)

https://meowlucian.github.io/gnu-cflow/

Author

Meow Lucian

Posted on

2022-05-20

Updated on

2022-07-06

Licensed under

Comments