[Courses] C Programming For Absolute Beginners, Lesson 1: Setting Up, First Program

Mel Chua mel at melchua.com
Mon Feb 6 08:33:46 UTC 2012


Since you're trying to do something that's not in the standard character 
set, you're using a code for Extended ASCII ("\u2764" in the printf() line)

> #include <stdio.h>
> main()
> {
> printf( "\nI \u2764 C!\n\n" );
> }

The warnings from the compiler means "hey wait, that's a universal 
character name from the Extended ASCII set -- not all C compilers are 
going to support that. However, I have a language standard called C99 
that *does* support it, and I turn it on by default because I'm gcc and 
I'm smart! So you're ok for now, but I just wanted to let you know that 
in case you decide to compile this with a non-Extended-ASCII-something 
in the future."

> $ gcc -o iheart iheart.c
> iheart.c: In function ‘main’:
> iheart.c:4:9: warning: universal character names are only valid in C++
> and C99 [enabled by default]
>
> The output of 'iheart' is correct, so I guess I should ignore this?

I'm not sure how other compilers are about handling extended ASCII, but 
with gcc you can use:

gcc -o iheart -Wall -std=c99 iheart.c

...to specify usage of the language -st(an)d(ard) C99, and that will 
make the warning go away.

--Mel


More information about the Courses mailing list