Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!swrinde!ucsd!hub.ucsb.edu!dschub!neptune!cdk From: cdk@neptune.dsc.com (Colin Kelley) Newsgroups: comp.lang.c++ Subject: one solution to the inlines in .h annoyance Message-ID: Date: 11 Jun 91 16:01:44 GMT Sender: news@dschub.dsc.com Lines: 42 Has anyone else out there been annoyed by the requirement that inline functions be placed in the header file? I understand why it's needed by the implementation, but it really clouds development, since as implementation details change, functions must be moved in and out of the header file as they change between inline and not. Well, this month we started in on code reviews for some C++ that I've been involved in writing, and we clearly had a problem. We wanted to review all the code as a unit--the fact that a routine was inline was worth noting, but not worth changing the order in which the functions were reviewed. So, here's my solution. Assume a module called with a header file 'module.h' and a C++ code file 'module.cc': I left only the class declarations in 'module.h', combining all the inline functions with those from 'module.cc' and placing all of this in 'module.code'. Those functions which were intended to be inline were so indicated with the 'inline' keyword, as before. At the end of 'module.h', I added the line #include "module-inline.h" I then wrote a tool that scans 'module.code' and extracts all functions beginning with 'inline' into 'module-inline.h', with the remainder of the file going to 'module.cc'. Of course this dependency is specified in the Makefile, so the extraction happens automatically. We've found this to be a real relief. Now we need only add or remove one word from the function definition to change its inline-ness. Has anyone else been through this same reasoning? What was your solution? If there's interest, I can post my inline extractor tool. - it's written in C++ (of course!) - it does a complete job of scanning C++ (comments, quoted string, \ escapes, etc., using a set of reusable C++ classes I had already written) - it makes liberal use of 'new', which makes it really simple but not amazingly efficient (but it still runs in 2 seconds on our Sequent) -Colin Kelley, Digital Sound Corporation cdk%neptune%dschub@hub.ucsb.edu ...!pyramid!ucsbcsl!dschub!neptune!cdk (805) 566-3000 x3175