Using the GNU Compilers on the CS Linux Machines

Current configurations for our classroom/lab machines include multiple versions of the GNU compilers:

Using make

I strongly encourage students in my classes to always compile C programs with at least the optional flag -Wall, and preferably several additional flags. No sensible person would type them all for every compile, but make can help. Create a file Makefile consisting of the single line

CFLAGS=-std=c99 -Wall -pedantic -O
(or whatever options you prefer -- note that the last one is a capital O). Then for example compile foo.c with
make foo
(The resulting executable will be called foo rather than the default a.out.)

If you're compiling C++ instead (or in addition), add this line to the Makefile:

CXXFLAGS=-std=c++98 -Wall -pedantic -O
(or whatever options you prefer -- if you're using the latest version of g++ you may want to replace -std=c++98 with -std=c++17). Then compile foo++.cpp with
make foo++




2019-06-05