Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typical C with C Preprocessor refactoring

Tags:

c

refactoring

I'm working on a refactoring tool for C with preprocessor support... I don't know the kind of refactoring involved in large C projects and I would like to know what people actually do when refactoring C code (and preprocessor directives)

I'd like to know also if some features that would be really interesting are not present in any tool and so the refactoring has to be done completely manually... I've seen for instance that Xref could not refactor macros that are used as iterators (don't know exactly what that means though)...

thanks

like image 496
LB40 Avatar asked Jul 14 '26 16:07

LB40


1 Answers

Anybody interested in this (specific to C), might want to take a look at the coccinelle tool:

Coccinelle is a program matching and transformation engine which provides the language SmPL (Semantic Patch Language) for specifying desired matches and transformations in C code. Coccinelle was initially targeted towards performing collateral evolutions in Linux. Such evolutions comprise the changes that are needed in client code in response to evolutions in library APIs, and may include modifications such as renaming a function, adding a function argument whose value is somehow context-dependent, and reorganizing a data structure. Beyond collateral evolutions, Coccinelle is successfully used (by us and others) for finding and fixing bugs in systems code.

like image 138
none Avatar answered Jul 16 '26 09:07

none