Formatting braces nested statements in a macro call [message #1817015] |
Thu, 14 November 2019 02:40 |
johan zahri Messages: 4 Registered: April 2019 |
Junior Member |
|
|
Hi,
Eclipse is formatting my code as follows:
error_t BAPP_APLO_process_login(BAPP_INSE_Request_p req) {
BAPP_COLO_iprintfln("Service login is called by req no %d!", req->rn);
BAPP_COST_trycatch_context_p ctx = NULL;
initial_try(&ctx);
exec(ctx,
{ BAPP_COLO_iprintfln("Try is working!"); BAPP_COLO_iprintfln("Try is working another line!"); BAPP_COLO_iprintfln("Try is woring one more time!"); });
catch_errno(ctx, errno_args(ENOMEM, EINVAL, 0),
{ BAPP_COLO_iprintfln("Caught an error!"); });
finally(&ctx);
return BAPP_OK;
}
Is there a way for me to tell eclipse to format it as such:
error_t BAPP_APLO_process_login(BAPP_INSE_Request_p req) {
BAPP_COLO_iprintfln("Service login is called by req no %d!", req->rn);
BAPP_COST_trycatch_context_p ctx = NULL;
initial_try(&ctx);
exec(ctx,
{
BAPP_COLO_iprintfln("Try is working!");
BAPP_COLO_iprintfln("Try is working another line!");
BAPP_COLO_iprintfln("Try is woring one more time!");
});
catch_errno(ctx, errno_args(ENOMEM, EINVAL, 0),
{ BAPP_COLO_iprintfln("Caught an error!"); });
finally(&ctx);
return BAPP_OK;
}
Thanks,
Johan
|
|
|
|
Re: Formatting braces nested statements in a macro call [message #1817523 is a reply to message #1817522] |
Mon, 25 November 2019 11:21 |
johan zahri Messages: 4 Registered: April 2019 |
Junior Member |
|
|
Another solution is to add /**/ before each statement and add tabs in the comment accordingly (rolling eyes)
exec(ctx,
{
/**/BAPP_COLO_dprintfln("Tests for selecting users!");
/**/
/**/if (test_select_users(con, &row_count)) {
/* */BAPP_COLO_eprintfln("Tests for selecting users failed");
/* */asprintf(&buff, "%s, test_select_users returned row_count: %d",
/* */BAPP_ERROR_DESC_USER_NOT_FOUND, row_count);
/* */throw_signal_code_with_simple_string_data(ctx, BAPP_ERROR_CODE_USER_NOT_FOUND, buff);
/**/} else {
/**/
/**/if (row_count > 0) {
/* */ko = test_delete_users(con);
/* */if (ko) {
/* */asprintf(&buff, "%s, test_delete_users returned error: %d",
/* */BAPP_ERROR_DESC_UNABLE_TO_DELETE_DB_ROW, ko);
/* */throw_signal_code_with_simple_string_data(ctx, BAPP_ERROR_CODE_UNABLE_TO_DELETE_DB_ROW, buff);
/* */}
/**/}
//
}
/**/BAPP_COLO_dprintfln("do other things using db!");
//
});
|
|
|
Powered by
FUDForum. Page generated in 0.02304 seconds