| ▲ | magicalhippo 2 hours ago | |
> DJ Delorie's djgpp project Fun story time. I started programming on Turbo Pascal. I had read some C code from those demo scene guides, so felt I understood it fairly well by the time I got my hands on a copy of djgpp. I decided to port a relatively simple program I had written in Turbo Pascal, about 300 LOC, line-by-line. It was a small demo just doing a simple rotating, texture-mapped triangle. I carefully converted it, and went over it several time one line at a time, fixing it until I had read over it three times and was happy. I then ran the djgpp compiler... Now, what I hadn't realized at the time was the difference between C and C++. The examples I had seen was C, and I didn't really know what C++ was. The compiler churned on my code and spit out about 3500 errors and warnings (it counted for me). I was shocked. How did my 300 line C program manage to produce over 10 errors and warnings per line, on average?! I spent a long time trying to figure this one out. The first error was inside the first function, and the error made no sense to me. After several days of carefully going over each line and banging my head against the table, I suddenly saw it. There, at the very start of the program, before the line the first error or warning pointed to. In Turbo Pascal I had used const to define things like screen width and height. So I'd have
Well, C doesn't have const, but I had picked up it had #define. However, my Turbo Pascal habits had kicked in, and so I had written
I removed the two semi-colons and the program compiled and ran just fine...I ended up staying in Turbo Pascal, I preferred a compiler that gave me sensible errors and quickly. I did pick up C++ much later, and I guess ironically came to appreciate its const correctness. | ||