static forwards
I just spent about 45 minutes trying to figure out why my program wouldn’t link. I was calling one function from another file, a not-uncommon occurrence. This fuction had previously been static, and I had removed the static from the definition, and added a forward to the header file. However, I was getting “undefined reference” errors when building. I banged my head on it over and over, even rebuilding the whole project, and still “undefined reference”. I finally discovered that there was a static forward for the function at the top of the file, and this was making the function static. No warning about redefinition, just failure to link. Let this be a lesson to you: alway search a file for forwards when changing the statichood of a function.
Discussion Area - Leave a Comment