Programming Gotchas for C++ and UNIX programmers

Garrett Mitchener

This is a selection of "Gotchas", silly things that keep your programs from compiling and working and waste a lot of your time. Hopefully, you will read this document and learn from the mistakes of others...


Table of Contents
1. C++ Compiler Gotchas
cpp: /var/tmp/cc0XVRDA.ii: No space left on device
Pre-processor directives (#include, #define, etc.) must end with a newline character
Shared libraries and illegal instruction errors
2. My program runs but it crashes
I get "Segmentation Fault" or "Bus Error" messages
What causes these errors?
How to I track them down?
3. Problems with specific functions and classes
Problems with stat and lstat
I called stat on a symbolic link, but the flags say it's not a link.
Okay, I used lstat, and I still can't get it to say that a file is really a link.
I've opened a lot of files or directories or sockets or pipes etc. and it won't let me open any more.