pip install jupygccLoad the extension.
```{python}
#| echo: false
#| output: false
%load_ext jupygcc
```Provides both %gcc line magic that takes a c filename as argument and %%gcc
cell magic that handle c code in the cell.
Line magic.
```{python}
%gcc ex1/main.c
```Cell magic.
#include <stdio.h>
int somme(int n) {
if (n <= 0)
return 0;
else
return (n + somme(n - 1));
}
int main() {
printf("u(%d= %d", 6, somme(6));
return 0;
}Currently, the kernel can't be configured and will always use:
-
-std=c99 -Wallfor C code -
Wrap the code in a
mainfunction if it doesn't already have one with:#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <math.h>
Currently, the only cell metadata handled is stdin.:
//| stdin: 10
int n;
printf("How many lines? ");
scanf("%d", &n);
printf("\n%d lines\n");
- Test:
hatch run test - Coverage:
htach run coverage
jupygcc is distributed under the terms of the MIT license.