Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » C-Code Style new line after function return type?
C-Code Style new line after function return type? [message #792218] Mon, 06 February 2012 14:11 Go to next message
Colin McInnes is currently offline Colin McInnes
Messages: 2
Registered: February 2012
Junior Member
I'm trying to customize the Allman code style to match the particular local quirks of my company's c-code style document, but I can't find a "new line after" option for return type of a function, or before a call to "return".

I'm using CDT 8 with Indigo.

Function Formatting: The function return type MUST be on a line by itself preceding the function.
int
my_function(void)

  not

int my_function(void)


Spacing around "return"

There MUST always be a blank line directly preceding a return statement within a given scope, except when there are no other statements within that scope. If a function does not return anything (i.e., is a void function), there MUST not be a blank line.
int
myfunc()
{
    function_call();

    return 1;
}

or

int
myfunc()
{
    if (1 == 2)
    {
        return 1;
    }

    return 0;
}


Re: C-Code Style new line after function return type? [message #792248 is a reply to message #792218] Mon, 06 February 2012 14:57 Go to previous messageGo to next message
Colin McInnes is currently offline Colin McInnes
Messages: 2
Registered: February 2012
Junior Member
Hmmm, the GNU style has this functionality, but I can't tell where it turned it off/on.
Re: C-Code Style new line after function return type? [message #792912 is a reply to message #792218] Tue, 07 February 2012 10:04 Go to previous messageGo to next message
Alan Kharsansy is currently offline Alan Kharsansy
Messages: 1
Registered: February 2012
Junior Member
Hi, I found a solution:

Export the current style XML and find a line like this:

<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration" value="insert"/>

Replace it with:

<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration" value="do not insert"/>

Cheers
Re: C-Code Style new line after function return type? [message #957433 is a reply to message #792912] Thu, 25 October 2012 04:13 Go to previous message
Pik Pok is currently offline Pik Pok
Messages: 1
Registered: October 2012
Junior Member
Hello.

I have problem with this new line. I try change this line (even I delet this), and it takes no effect. I have still new line after return type in function declaration and definition. It looks pretty nasty.

I try it on Helios and Juno.

Please help


Previous Topic:Eclipse Running TOO Slow on Laptop
Next Topic:Unresolved Inclusion of BluetoothAPIs and bthdef.h
Goto Forum:
  


Current Time: Fri Aug 22 04:14:34 EDT 2014

Powered by FUDForum. Page generated in 0.02014 seconds