Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335442

Summary: create a function definition "skeleton" from a function call site
Product: [Tools] CDT Reporter: m c <carifio>
Component: cdt-editorAssignee: Project Inbox <cdt-editor-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: enhancement    
Priority: P3 CC: aegges, cdtdoug, elaskavaia.cdt, kosashi, malaperle, yevshif
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description m c CLA 2011-01-26 08:34:12 EST
Build Identifier: 20100917-0705

I'm using cdt 7 on helios on ubuntu 10.10. Also using the Linux toolchain (gcc, etc). Suppose I have some C code like the following
(which I just made up for this example):

  int i = 5;
  float f = 5.0;
  char* message = "how arbitrary";

  some_local_function(i, f, message);

Is there some tool/function/magic that would generate the prototype for
function 'some_local_function' from it's call site? In this case,
I would get:

void
some_local_function(int i, float f, char* message) {
  // Add your code here
}

... placed *above* the function that made the call. I couldn't find anything like this. I'm just doing it by hand. I can do this in Java with other IDEs (I think intellij idea 10 does it).

Thanks. 

Reproducible: Always
Comment 1 Axel Mueller CLA 2011-01-26 11:28:26 EST
(In reply to comment #0)
> ... placed *above* the function that made the call.
I think we have to distinguish between two use cases.
1) create a local function prototype (as suggested)
2) create a function prototype in another source file
=> - dialog to choose which source file
   - put prototype in the source file
   - put declaration in the corresponding header file
   - put an include statement in the original file
Comment 2 Tomasz Wesolowski CLA 2011-06-16 11:50:50 EDT
I think this sounds like one of quick fix proposals on the problem marker which would be currently generated by Codan in the place of unknown function call (at least in C++; in C calling an undefined function is legal AFAICR).