Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Is it possible to auto generate a source or header file?
Is it possible to auto generate a source or header file? [message #1806306] Tue, 07 May 2019 14:20 Go to next message
Robert Murch is currently offline Robert MurchFriend
Messages: 13
Registered: August 2018
Junior Member
I was wondering, lets say I build some function like:

double median(vector<double> vec)
{
	typedef vector<double>::size_type vec_sz;

	vec_sz size = vec.size();
	if(size == 0)
	{
		throw domain_error("median of an empty vector");
	}

	sort(vec.begin(), vec.end());

	vec_sz mid = size/2;

	return size % 2 == 0 ? (vec[mid] + vec[mid-1]) / 2 : vec[mid];
}


is there a method for me to auto generate a source file and a header file for this function? For instance, if I want to move this function out of the main body of the program and create a separate .cpp file for it, with it's own header file, can I just right-click the function or hit a quick key to have that happen automatically for me? If not, then lets say I already built the source file for it, can I just right-click it in there and auto generate a header for it?
Re: Is it possible to auto generate a source or header file? [message #1806326 is a reply to message #1806306] Tue, 07 May 2019 18:25 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
I'm pretty sure the answer is No.
There are utilities to do that though.
I used one years ago for a project without header files.
Can't remember its name.

If all you have is that one function, do
File --> New --> Header File
then cut and paste the first line (function prototype)
into it followed by a ';'
Re: Is it possible to auto generate a source or header file? [message #1806333 is a reply to message #1806326] Tue, 07 May 2019 19:50 Go to previous messageGo to next message
Robert Murch is currently offline Robert MurchFriend
Messages: 13
Registered: August 2018
Junior Member
@David Vavra Okay, yeah I wasn't sure so I figured I would ask. I was only wondering cause I thought it would be neat and after building a project and separating out like 20 source files with 20 different headers I thought to myself: "Man I wish this was more automated"...
Re: Is it possible to auto generate a source or header file? [message #1806406 is a reply to message #1806333] Wed, 08 May 2019 14:35 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
You might want to look into this:
https://www.hwaci.com/sw/mkhdr/
Previous Topic:Configure Eclipse to run make on remote host
Next Topic:Expressions view does not repaint
Goto Forum:
  


Current Time: Thu Apr 25 06:35:09 GMT 2024

Powered by FUDForum. Page generated in 0.03060 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top