Web Analytics

igcc

⭐ 209 stars Spanish by alexandru-dinu

🌐 Idioma

GCC Interactivo

tests contrib Code style: black

[!NOTA]
El repositorio original de Andy Balaam está aquí: https://codeberg.org/andybalaam/igcc.
En este fork, he realizado algunas refactorizaciones y tratado de hacerlo más fácil de usar.

[!ADVERTENCIA]
Este proyecto es un intento improvisado de conseguir un ciclo de retroalimentación más corto al trabajar con C/C++ en algunos casos y obviamente no está destinado para nada serio.

GCC interactivo (igcc) es un bucle de lectura-evaluación-impresión (REPL) para C/C++. Funciona manipulando un archivo fuente base con comandos del usuario, compila la fuente después de cada modificación, luego ejecuta el binario resultante y recoge su stdout y stderr. Se admite la entrada de varias líneas (bloques), por lo que puedes agregar múltiples líneas de una vez e invocar el compilador solo una vez (ver ejemplos abajo).

Puedes incluir varios archivos de cabecera. Para mayor comodidad, se incluye un encabezado por defecto: boilerplate.h. Además, using namespace std; no está disponible por defecto, pero puedes agregarlo explícitamente (ver ejemplo abajo).

Diversos aspectos de igcc pueden configurarse, consulta config.yaml.

Primeros pasos

La forma más sencilla de empezar es usar pipx:
pipx install git+https://github.com/alexandru-dinu/igcc.git
Alternativamente, también puedes usar uv:
uv tool run git+https://github.com/alexandru-dinu/igcc
Y para desarrollo:
git clone https://github.com/alexandru-dinu/igcc.git
cd igcc
uv sync

Argumentos disponibles:

usage: igcc [-h] [-I INCLUDE [INCLUDE ...]] [-L LIBDIR [LIBDIR ...]]
            [-l LIB [LIB ...]]

options: -h, --help show this help message and exit -I INCLUDE [INCLUDE ...] Add INCLUDE to the list of directories to be searched for header files. -L LIBDIR [LIBDIR ...] Add LIBDIR to the list of directories to be searched for library files. -l LIB [LIB ...] Search the library LIB when linking.

El código será compilado con GCC (g++) y los resultados (si los hay) se mostrarán. Escriba .h para ayuda:

$ igcc
[1]> .h
.h  Show this help message
.e  Show the last compile errors/warnings
.l  List the code you have entered
.L  List the whole program as given to the compiler
.r  Redo undone command
.u  Undo previous command
.q  Quit

Ejemplos

$ igcc
[1]> int a = 5;
[2]> a += 2;
[3]> using namespace std;
[4]> cout << a << endl;
7

[5]> int b = 17; [6]> a *= b; [7]> cout << a << ", " << b << endl; 119, 17

[8]> .L #include "boilerplate.h" using namespace std;

int main(void) { int a = 5; a += 2; cout << a << endl; int b = 17; a *= b; cout << a << ", " << b << endl;

return 0; }

La entrada de varias líneas es compatible (ver multiline_marker en la configuración). El beneficio es evitar múltiples llamadas al compilador.

$ igcc
[1]> .m
... for (int i = 0; i < 10; i++) {
...   std::cout << i << " ";
... }
... std::cout << "\n";
... .m
0 1 2 3 4 5 6 7 8 9

Puede incluir encabezados:

$ igcc
[1]> #include 
[2]> std::vector xs{1,2,3};
[3]> xs.push_back(17);
[4]> .m
... for (auto x : xs) {
...   std::cout << x << " ";
... }
... .m
1 2 3 17

Las bibliotecas pueden ser enlazadas:

$ igcc -lpthread
[  1]> #include 
[  2]> pthread_t thr;
[  3]> const char* msg = "Hello, World!";
[  4]> // assuming print_msg is defined somewhere
[  5]> int ret = pthread_create(&thr, NULL, print_msg, (void*) msg); pthread_join(thr, NULL);
Hello, World!

También puedes deshacer comandos:

$ igcc
[1]> int x = 2
 Compile error - type .e to see it

[2]> .e : In function ‘int main()’: :7:5: error: expected ‘,’ or ‘;’ before ‘return’ :5:9: warning: unused variable ‘x’ [-Wunused-variable]

[2]> .u Undone int x = 2 [1]> int x = 2; [2]> .L #include "boilerplate.h"

int main(void) { int x = 2;

return 0; }

... o rehacer comandos previamente deshechos:

$ igcc
[1]> int x = 2;
[2]> std::cout << x;
2
[3]> .u
Undone std::cout << x;
[2]> .L
#include "boilerplate.h"

int main(void) { int x = 2;

return 0; } [2]> .r Redone std::cout << x; 2 [3]> .L #include "boilerplate.h"

int main(void) { int x = 2; std::cout << x;

return 0; }

Trabajo futuro

Vea https://github.com/alexandru-dinu/igcc/issues

Proyectos similares

Créditos

--- Tranlated By Open Ai Tx | Last indexed: 2025-12-11 ---