Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "header guard"
-
So for almost all of my c++ assignments I've recieved various emails from the instructor about things like "incorrect header guard" and "library inclusions out of order".
The first being that I didn't include the namespace inside of the guard (I did "FILENAME_H" instead of "NAMESPACE_FILENAME_H")
The second is that I accidentally included header files from my project before any of the standard libraries. This one wasn't even intentional, it was caused by vscode when it formatted/prettified the file.
EX:
#include "test.h"
#include <iostream>
In my opinion these seem pretty nitpicky and, especially that first one, appear to be more like naming conventions or best practices than something to deduct marks for.
On the flip side though I did accidentally store a couple functions in the global namespace which I understand isn't particularly safe. I also made a couple one line conditional statements that simply never evaluate to true, but I didn't think this was a huge deal.
I don't normally code in any of the c languages outside of college so I'm not sure how important these are to actually follow. I've apparently been deducted an entire 10 percent off the assignment because of the head guard. I know that every professor has different criteria for deducting marks, but even this seemed rather unnecessary.
What does everyone think?11 -
The other day I was working with libpulse in a Qt project. Because I didn't like to deal with a C library from C++ code I copied wrapper code from a well-proven project. Suddenly the wildest compile errors occurred when I only tried to include a header from the new code. After hours of frustration towards me, C++, the compiler and everything involved I discovered that one of the headers I copied had the same include guard as one of the existing classes.