Skip to main content
5 events
when toggle format what by license comment
Mar 27, 2014 at 15:52 comment added user_name Ok, I can see that becoming an issue when the code gets more and more complicated. Thanks for the advice.
Mar 27, 2014 at 15:45 comment added drodri Sure, it is a good practice, though it is not needed in your example. It avoids the same header file to be included twice in a compilation file. Imagine a.cpp->(b.h and c.h) and b.h->c.h. That will duplicate the contents of c.h while compiling a.cpp. The #pragma once avoid this. Also guard directives #ifndef _MY_FILE_H_INCLUDED #define _MY_FILE_H_INCLUDED are common for this. Note, however, that as Peter R. Bloomfield points out, it might be better to put the implementation of CalculateCRC16 in a cpp file, and leave just the declaration in the header file.
Mar 27, 2014 at 14:44 comment added user_name Thanks, it works just fine now. Could you please explain the need of the pragma?
Mar 27, 2014 at 14:41 vote accept user_name
Mar 27, 2014 at 14:33 history answered drodri CC BY-SA 3.0