I’ve been teaching myself cpp sporadically from ‘accelerated C++’ and recently I noticed that when I forgot my #include <algorithm> statement, my code (which includes transform and find_if) compiled and ran successfully anyways. After this, I tried removing all standard header include statements altogether and found that my code still ran.
I assume my inability to understand preprocessor commands will be resolved by the time I finish the book, but for now I just need to know how to make sure that my terminal yells at me when I make the header improperly so I can learn where things are located in the std library.
I am running OS 10.6.5 so I have to compile my code with the following unix exe file:
CC = g++
CFLAGS = -Wall
PROG = TrainingProject23
SRCS = TrainingProject23.cpp
ifeq ($(shell uname),Darwin)
LIBS = -framework OpenGL -framework GLUT
else
LIBS = -lglut
endif
all: $(PROG)
$(PROG): $(SRCS)
$(CC) $(CFLAGS) -o $(PROG) $(SRCS) $(LIBS)
clean:
rm -f $(PROG)
it includes the build protocol for OpenGL because I am learning that as well and it easy enough to use this file to compile all my C++ projects. I don’t really understand the Makefile besides how to change the src file and program name, I just got it off the internet.
Standard library headers are allowed to include other standard library headers. So if you e.g.
#include <string>; your implementation is allowed (but not required to) include every other standard library header there is, including<algorithm>. In your case, that probably happened, but it’s nothing you should rely on.