Enter-tainer / cxx2flow

将 C/C++ 代码转换成流程图 / Turn your C/C++ code into flowchart
MIT License
737 stars 61 forks source link

Error report: I don't know why it can't find out the function,so I just sent to the C source file #54

Closed ArvinChengcheng closed 1 week ago

ArvinChengcheng commented 1 week ago

this is what I using image this is the C file and please double click the bat file, it can repeat the error: temp.zip

ArvinChengcheng commented 1 week ago

when I try to duplicate the function name, it passed. strange! image

Enter-tainer commented 1 week ago

could you run it without using macros?

ArvinChengcheng commented 1 week ago

It can work when I delete the macro but the last function(initial_diag_evaluate) also have the macro FUNC(...)

Enter-tainer commented 1 week ago

i guess the macro has confused the parser so it behaves weirdly.

Enter-tainer commented 1 week ago

btw, there is an option to tell cxx2flow to expand macros before parsing it. can you try it?

ArvinChengcheng commented 1 week ago

How to tell cxx2flow? could you please raise a example?

Enter-tainer commented 1 week ago
Convert your C/C++ code to control flow chart

Usage: cxx2flow [OPTIONS] [INPUT] [FUNCTION]

Arguments:
  [INPUT]     Sets the path of the input file. e.g. test.cpp
              If not specified, cxx2flow will read from stdin.
  [FUNCTION]  The function you want to convert. e.g. main [default: main]

Options:
  -o, --output <OUTPUT>  Sets the output file.
                         If not specified, result will be directed to stdout.
                         e.g. graph.dot
  -c, --curly            Sets the style of the flow chart.
                         If specified, output flow chart will have curly connection line.
      --cpp              Use C preprocessor.
  -t, --tikz             Use tikz backend.
  -d, --dump-ast         Dump AST(For debug purpose only).
  -h, --help             Print help information
  -V, --version          Print version information

Note that you need to manually compile the dot file using graphviz to get SVG or PNG files.

EXAMPLES:
    cat main.cpp | cxx2flow | dot -Tsvg -o test.svg
    cxx2flow test.cpp | dot -Tpng -o test.png
    cxx2flow main.cpp my_custom_func | dot -Tsvg -o test.svg

In short, adding --cpp should work. It would call cpp to preprocess the code

ArvinChengcheng commented 1 week ago

actually, the Macro is be defined in other .h file so it may not solve my problem...

when I run "cxx2flow.exe --cpp D:\SDD_autogenerate\temp\TrailerLights_SwC.c TrailerLights" it told me "Error: ←[31mx←[0m program not found" which program it need?

Enter-tainer commented 1 week ago

You need cpp, which is c pre processor.

Enter-tainer commented 1 week ago

In any means, I can confirm this is not a cxx2flow's bug. For your problem, you may either remove the macro when generating flowcharts, or add macro definition so cxx2flow can read it. I will close this issue.