Estaba buscando información de como configurar el formateo de documentos en visual studio code para C, y esta el atajo control+shift+i
pero me deja los corchetes por debajo de la función buscando mas información entro a las configuraciones
Y me abre un monton de configuraciones: Archivo: .editorconfig
[*]
cpp_indent_braces=false
cpp_indent_multi_line_relative_to=innermost_parenthesis
cpp_indent_within_parentheses=indent
cpp_indent_preserve_within_parentheses=false
cpp_indent_case_labels=false
cpp_indent_case_contents=true
cpp_indent_case_contents_when_block=false
cpp_indent_lambda_braces_when_parameter=true
cpp_indent_goto_labels=one_left
cpp_indent_preprocessor=leftmost_column
cpp_indent_access_specifiers=false
cpp_indent_namespace_contents=true
cpp_indent_preserve_comments=false
cpp_new_line_before_open_brace_namespace=ignore
cpp_new_line_before_open_brace_type=ignore
cpp_new_line_before_open_brace_function=ignore
cpp_new_line_before_open_brace_block=ignore
cpp_new_line_before_open_brace_lambda=ignore
cpp_new_line_scope_braces_on_separate_lines=false
cpp_new_line_close_brace_same_line_empty_type=false
cpp_new_line_close_brace_same_line_empty_function=false
cpp_new_line_before_catch=true
cpp_new_line_before_else=true
cpp_new_line_before_while_in_do_while=false
cpp_space_before_function_open_parenthesis=remove
cpp_space_within_parameter_list_parentheses=false
cpp_space_between_empty_parameter_list_parentheses=false
cpp_space_after_keywords_in_control_flow_statements=true
cpp_space_within_control_flow_statement_parentheses=false
cpp_space_before_lambda_open_parenthesis=false
cpp_space_within_cast_parentheses=false
cpp_space_after_cast_close_parenthesis=false
cpp_space_within_expression_parentheses=false
cpp_space_before_block_open_brace=true
cpp_space_between_empty_braces=false
cpp_space_before_initializer_list_open_brace=false
cpp_space_within_initializer_list_braces=true
cpp_space_preserve_in_initializer_list=true
cpp_space_before_open_square_bracket=false
cpp_space_within_square_brackets=false
cpp_space_before_empty_square_brackets=false
cpp_space_between_empty_square_brackets=false
cpp_space_group_square_brackets=true
cpp_space_within_lambda_brackets=false
cpp_space_between_empty_lambda_brackets=false
cpp_space_before_comma=false
cpp_space_after_comma=true
cpp_space_remove_around_member_operators=true
cpp_space_before_inheritance_colon=true
cpp_space_before_constructor_colon=true
cpp_space_remove_before_semicolon=true
cpp_space_after_semicolon=false
cpp_space_remove_around_unary_operator=true
cpp_space_around_binary_operator=insert
cpp_space_around_assignment_operator=insert
cpp_space_pointer_reference_alignment=left
cpp_space_around_ternary_operator=insert
cpp_wrap_preserve_blocks=one_liners
estuve probando configuraciones y me molestaba que siguiera todo igual independiente de los cambios que hiciera ejempló si quiero cambiar el orden de las coma con la instrucción cpp_space_after_comma=true
la cambio por false
le doy a guardar y seguido apretó control+shift+i
, el cambio que hice no se aplica sigue exactamente igual, el caso es que me gustaría poner los corchetes al lado de la función y no por debajo pero aun así no se me aplica los cambios y no encuentro la instrucción para hacer el cambio de corchetes, ¿alguna solución para que los cambios se apliquen al formateo?¿Cual es la instrucción que me deja cambiar los corchetes?
la informacion la saque de aqui:https://docs.microsoft.com/en-us/visualstudio/ide/cpp-editorconfig-properties?view=vs-2019
Lo que quiero
void funcion(){
codigo....
}
lo que tengo
void funcion()
{
codigo....
}
Archivo : c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/mpich",
"/usr/include/x86_64-linux-gnu/mpich" //libreria con la cual trabajo
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
Como se puede ver en el Archivo.c se tiene un código dentando con los paréntesis al lado de la función Archivo.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "mpi.h"
#define TAG1 1
#define TAG2 2
#define MASTER 0
#define X1 1
#define X2 2
int whoami, hm_are_we;
MPI_Status status;
/*
*
* Shows the usage of the program
*
*/
void Usage(char *message){
printf("\nUsage : mpirun -np 3 %s a b c\n", message);
fflush(stdout);
}
/*
*
*/
void main(int argc, char *argv[]){
char processor_name[MPI_MAX_PROCESSOR_NAME]; //T0
int me; //T1
float coef[3]; //T2
float delta; //T3
float x; //T4
float x1; //T5
float x2; //T6
MPI_Init(&argc, &argv); //T7
MPI_Comm_size(MPI_COMM_WORLD, &hm_are_we); //T8
if (hm_are_we == 3){ // T9
MPI_Comm_rank(MPI_COMM_WORLD, &whoami); //T11
MPI_Get_processor_name(processor_name, &me); //T12
printf("\n\nProcess [%d] Alive on %s\n", whoami, processor_name); //T13
fflush(stdout); //14
if (whoami == MASTER) //T15
if (argc == 4){ //T17
coef[0] = atof(argv[1]); //T19
coef[1] = atof(argv[2]); //T20
coef[2] = atof(argv[3]); //T21
MPI_Send(&coef, 3, MPI_FLOAT, X1, TAG1, MPI_COMM_WORLD); //T22
MPI_Send(&coef, 3, MPI_FLOAT, X2, TAG1, MPI_COMM_WORLD); //T23
MPI_Recv(&x1, 1, MPI_FLOAT, X1, TAG2, MPI_COMM_WORLD, &status); //T24
MPI_Recv(&x2, 1, MPI_FLOAT, X2, TAG2, MPI_COMM_WORLD, &status); //T25
printf("\n\nReal Solutions of %fx^2 + %fx + %f = 0 are x1 = %f x2 = %f\n\n", coef[0], coef[1], coef[2], x1, x2); //T26
fflush(stdout); //T27
}
else //T18
Usage(argv[0]); //T28
else{ //T16
MPI_Recv(&coef, 3, MPI_FLOAT, MASTER, TAG1, MPI_COMM_WORLD, &status); //T29
delta = sqrt(coef[1] * coef[1] - 4.0 * coef[0] * coef[2]); //T30
if (whoami == X1) //T31
x = (-coef[1] + delta) / (2.0 * coef[0]); //T33
else //T32
x = (-coef[1] - delta) / (2.0 * coef[0]); //T34
MPI_Send(&x, 1, MPI_FLOAT, MASTER, TAG2, MPI_COMM_WORLD); //T35
}
} // T10
MPI_Finalize(); //T36
}
si aplico el formato control+shift+i
queda de la siguiente forma:
Archivo.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "mpi.h"
#define TAG1 1
#define TAG2 2
#define MASTER 0
#define X1 1
#define X2 2
int whoami, hm_are_we;
MPI_Status status;
/*
*
* Shows the usage of the program
*
*/
void Usage(char *message)
{
printf("\nUsage : mpirun -np 3 %s a b c\n", message);
fflush(stdout);
}
/*
*
*/
void main(int argc, char *argv[])
{
char processor_name[MPI_MAX_PROCESSOR_NAME]; //T0
int me; //T1
float coef[3]; //T2
float delta; //T3
float x; //T4
float x1; //T5
float x2; //T6
MPI_Init(&argc, &argv); //T7
MPI_Comm_size(MPI_COMM_WORLD, &hm_are_we); //T8
if (hm_are_we == 3)
{ // T9
MPI_Comm_rank(MPI_COMM_WORLD, &whoami); //T11
MPI_Get_processor_name(processor_name, &me); //T12
printf("\n\nProcess [%d] Alive on %s\n", whoami, processor_name); //T13
fflush(stdout); //14
if (whoami == MASTER) //T15
if (argc == 4)
{ //T17
coef[0] = atof(argv[1]); //T19
coef[1] = atof(argv[2]); //T20
coef[2] = atof(argv[3]); //T21
MPI_Send(&coef, 3, MPI_FLOAT, X1, TAG1, MPI_COMM_WORLD); //T22
MPI_Send(&coef, 3, MPI_FLOAT, X2, TAG1, MPI_COMM_WORLD); //T23
MPI_Recv(&x1, 1, MPI_FLOAT, X1, TAG2, MPI_COMM_WORLD, &status); //T24
MPI_Recv(&x2, 1, MPI_FLOAT, X2, TAG2, MPI_COMM_WORLD, &status); //T25
printf("\n\nReal Solutions of %fx^2 + %fx + %f = 0 are x1 = %f x2 = %f\n\n", coef[0], coef[1], coef[2], x1, x2); //T26
fflush(stdout); //T27
}
else //T18
Usage(argv[0]); //T28
else
{ //T16
MPI_Recv(&coef, 3, MPI_FLOAT, MASTER, TAG1, MPI_COMM_WORLD, &status); //T29
delta = sqrt(coef[1] * coef[1] - 4.0 * coef[0] * coef[2]); //T30
if (whoami == X1) //T31
x = (-coef[1] + delta) / (2.0 * coef[0]); //T33
else //T32
x = (-coef[1] - delta) / (2.0 * coef[0]); //T34
MPI_Send(&x, 1, MPI_FLOAT, MASTER, TAG2, MPI_COMM_WORLD); //T35
}
} // T10
MPI_Finalize(); //T36
}
.c
y.exe
el contenido del .c es realmente necesario?.json
que tienen montones de parametros en una carpeta oculta.json
que me incluye un path de una libreria que no tenia y el compilador