I think it's MSVC specific.
How about just randomly spam some letters on the keyboard . Or use a pseudo random number generator while you are at it.
I think it's MSVC specific.
How about just randomly spam some letters on the keyboard . Or use a pseudo random number generator while you are at it.
The obvious solution that keeps in line with dwks' suggestion is DIRECTORY_HEADER_H. I have used NAMESPACE_CLASS_H, though I suppose FILENAME_H_MONTH_DAY_YEAR works well too.But then what happens if you have two include files with the same name in different directories?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Is there anything wrong with just using a random number? I actually wasn't joking .
I do not think so, other than that it could be troublesome since the probability of having duplicate names is rather small anyway, especially when things like namespace names, directory names, or the current date is added in, and these can come to mind immediately.Is there anything wrong with just using a random number?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I think she means prefix.
For example, I call my files PROJECT_PATH_TO_FILENAME_SR_H
The SR_H suffix is personal for me and should guarantee that my guards never collide with those of other people (unless they have the initials S.R. too).
#ifndef IOCHAIN_INFRASTRUCTURE_CHAIN_HPP_SR_H
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
I generally use COMPANYINITIALS_HEADERNAME, since it is unlikely that it will collide with a header of someone else at the company while im here, and what happens after isnt my responsibility.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
In a project that made use of xuni, I accidentally created a header file called "graphics.h" -- which xuni also has. Both were using GRAPHICS_H for the inclusion guard. So now all of xuni's header files have guards like XUNI_GUARD_GRAPHICS_H.
It took me quite a while to figure out what was wrong. Inclusion guards aren't supposed to fail. So I can see why someone might want to put a random number or other unique string inside them . . . .
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Or simply use #pragma once. Though not standard, according to wikipedia it's "widely supported", "without possibility for name clashes" and "increased compilation speed".
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Yes, apparently even GCC supports it, though it's "deprecated". (I'm assuming MSVC does too; it likes #pragmas.)
On the other hand, apparently it doesn't always work, while inclusion guards do.
http://groups.google.com/group/comp....279780c364628f
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
So what is it good for then? Does it "speed up compile times" or something?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.