Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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: Wed Jul 23 15:50:28 EDT 2025

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

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

Back to the top