c++ - What does this naming convention for headers refer to? -


i studying include guards in c++ , came across naming convention wikipedia:

creatorsname_yyyymmdd_hhmmss 

i timestamp say

#ifndef creatorsname_yyyymmdd_hhmmss

#define creatorsname_yyyymmdd_hhmmss

#endif

then how compiler know headername.h ?

it's convenient way store documentation person wrote module , when, guarantees uniquness of guard(through date), , provides additional information others referencing module. particularly if believe there problem it's corresponding implementation, have write to. otherwise, creator of module can forget add in documentation are.

#ifndef chris_20140807_011555  #define chris_20140807_011555  struct foo {     int member; };  #endif /* chris_20140807_011555 */ 

alternatively, this, doesn't provide additional information , adding documentation @ top easy forget.(though honest, should become habbit, , should not forgotten). but, still motivation such practices, despite option below being more used.

/* * author: chris * date: july 7, 2013 * * these comments easy forget */ #ifndef filename_h #define filename_h  struct foo {     int member; };  #endif /* filename_h */ 

this:

#ifndef aaaa  #define aaaa  struct foo {     int member; };  #endif  

and

#pragma once  struct foo {     int member; }; 

all of these code snippets accomplish exact same thing.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -