Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract declarations (a .hpp file) from implementation (a .cpp file)?

Tags:

c++

I was wondering if there was a tool (maybe GNU C++ compiler) to obtain from a .cpp file full of functions a .hpp file with the mentioned functions declarations.

Example:

I have:
magic.cpp

int foo() { return 42; }
char bar() { return 'z'; }

And I would like to obtain this after applying the wonderful tool:
magic.hpp

int foo();
char bar();
like image 285
msemelman Avatar asked Dec 22 '11 23:12

msemelman


1 Answers

On Debian-based distributions:

apt-get install cproto

Then cproto magic.cpp gives the following output:

/* magic.cpp */
int foo(void);
char bar(void);
like image 61
Eduardo Ivanec Avatar answered Nov 03 '22 00:11

Eduardo Ivanec