C++ Reference Notes#

These references are useful for durable C++ language and programming-practice questions that apply across CS 135 and CS 202.

The current course syllabus, assignment instructions, and applicable CSN or college policies take precedence over anything on this website or in external reference material.

C++ language references#

  • cppreference.com is the main C++ language and standard-library reference. It is detailed and sometimes dense, but it is one of the best places to verify syntax, library behavior, and language rules.
  • C++ Core Guidelines collects modern C++ design and style guidance. Some recommendations may be beyond CS 135 or CS 202, so use course standards first.
  • GCC online documentation documents the compiler family behind g++.

Secure coding references#

  • SEI CERT C++ Coding Standard describes security-oriented C++ rules and recommendations. It is a professional reference, not a replacement for course instructions.

Course reminders#

Compile with the flags required by your course documents:

g++ $CXXFLAGS main.cpp -o main

Read compiler messages from top to bottom. The first error is often the one that caused the later messages.

Before submitting, compile and run your program on Bellagio or the approved course environment. A program that works only on your own computer may still need correction before submission.

Use Debugging with GDB when a program compiles but crashes, stops unexpectedly, or produces the wrong result.

For supplemental tools such as lint, cppcheck, cpplint, astyle, aspell, doxygen, Catch2, Valgrind, make, and GDB, see Supplemental Tools.

What is CXXFLAGS?#

CXXFLAGS is an environment variable. It stores a predefined set of options for the C++ compiler. When you run a command such as:

g++ $CXXFLAGS file.cpp -o program

the shell replaces $CXXFLAGS with the compiler settings configured for the Bellagio environment. That lets everyone compile under the same conditions without needing to memorize or retype every compiler option.

To view the value on Bellagio, run:

echo $CXXFLAGS

That prints the full list on one line. To make the output easier to read, show one option per line:

echo $CXXFLAGS | tr ' ' '\n'

The Bellagio CXXFLAGS setting defines how g++ behaves for course work. It sets the C++ language standard, includes debug information, and enables a large collection of warnings that help detect common programming mistakes. Some warnings are treated as errors, which means the compiler will not produce an executable until the issue is corrected.

These settings also support safer and more consistent C++ development. They help catch risky constructs, especially as programs become more complex. You may not notice every option directly, but using $CXXFLAGS helps enforce the same standards for everyone.

The purpose of CXXFLAGS is consistency and quality. Programs should be compiled with the same strict settings used for the course so that code is not only correct, but also well-formed, portable, and easier to maintain.

Note: The page you are viewing
is not sanctioned by CSN.