"But the kernel will also display compilations warnings and errors if we have some. Let's try to remove the `#include <stdio.h>` statement, which if necessary for `printf` to work."
"/var/folders/31/qct57s856n5f0b2r4tgbmn1c0000gn/T/tmp0Qan0v.c:2:5: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]\n",
" printf(\"Hello world\\n\");\n",
" ^\n",
"/var/folders/31/qct57s856n5f0b2r4tgbmn1c0000gn/T/tmp0Qan0v.c:2:5: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'\n",
"1 warning generated.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello world\n"
]
}
],
"source": [
"int main() {\n",
" printf(\"Hello world\\n\");\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can see that the warning are displayed, but the code is still executed."
"/var/folders/31/qct57s856n5f0b2r4tgbmn1c0000gn/T/tmpw4Kz3c.c:2:5: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]\n",
" printf(\"Hello world\")\n",
" ^\n",
"/var/folders/31/qct57s856n5f0b2r4tgbmn1c0000gn/T/tmpw4Kz3c.c:2:5: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'\n",
"/var/folders/31/qct57s856n5f0b2r4tgbmn1c0000gn/T/tmpw4Kz3c.c:2:26: error: expected ';' after expression\n",
" printf(\"Hello world\")\n",
" ^\n",
" ;\n",
"1 warning and 1 error generated.\n",
"[C kernel] GCC exited with code 1, the executable will not be executed"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": []
}
],
"source": [
"int main() {\n",
" printf(\"Hello world\")\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can see that the errors and warnings are shown, but the code is not executed. The retcode is also added to the end of `stderr`"