yangchi / C_struct_dot_generator

Scan a dir of C code, find structs, and generate a dot file to be used by Graphviz to draw a graph to represent relations among them.
4 stars 0 forks source link

Same struct name on two sides of an #ifdef breaks #1

Open ghost opened 7 years ago

ghost commented 7 years ago
#ifdef IS_32_BITS
typedef mystruct u32
#else
typedef mystruct u64
#endif
current value for key mystruct is u32
trying to add new value: u64

Traceback (most recent call last):
  File "./structs2dot.py", line 246, in <module>
    write_dot_file()
  File "./structs2dot.py", line 217, in write_dot_file
    relation_mapper = relation_builder()
  File "./structs2dot.py", line 118, in relation_builder
    mapper = alias_gen()
  File "./structs2dot.py", line 52, in alias_gen
    add_mapper(splitted[2], splitted[1], mapper)
  File "./structs2dot.py", line 188, in add_mapper
    assert key not in mapper.keys() or mapper[key] == value
AssertionError

How to make work with output of C preprocessor?

ghost commented 7 years ago

Found one that works right. https://github.com/gelim/StructViz