I’m staring to learn C, and via help of youtube I could download 6.3.0 compiler version, though my textbook is referring to 4.3.3.
I’m purposefully trying to get warnings (as a task to learn to interpret them) for a Hello World program without getting an error, but I don’t get any.
I took away return(0)
and then took away the second quote mark in printf
, but PowerShell just executes the program after compilation without giving me any warnings.
I tried -W
, -Wall
, -Wextra
, -Wreturn-type
and even found -Wdouble-promotion
, but to no success.
Original code:
/*
* program that writes 'hello world'
*/
#include <stdio.h>
int main()
{
printf("Hello, world!n");
return 0;
}
Program code for testing out warnings:
#include <stdio.h>
int main()
{
printf("Hello, world!n);
/* took away the second quote mark
* and the return(0) operation
* to test warnings
*/
}
Compiling and running the program results in
> gcc -Wall -o warning hello_warning.c
PS C:UserssofyaOneDriveДокументыпрограммки> ./warning
Hello, world!
Instead of giving me as well some of the warnings my textbook suggests, such as:
warning: missing terminating " character
Sofia Zaiafarova is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5