Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for May 16, 2013
A look at the PyPy 2.0 release
PostgreSQL 9.3 beta: Federated databases and more
LWN.net Weekly Edition for May 9, 2013
(Nearly) full tickless operation in 3.10
Posted Nov 2, 2011 21:31 UTC (Wed) by khim (subscriber, #9252)
When include files are copied around they sometimes treated as the same from "#pragma once" POV (if copying process keeps the timestamps) and sometimes as different (if you put them in GIT and pull back).
Thus "#pragma once" is great way to create unreproducible build failures. With explicit include guard you sometimes trigger the GCC optimization (GCC does not reread file with include guard it it can understand that it's the same file) and sometimes it fails and GCC actually loads and parses file again - but it only affects compilation speed, never correctness.
Posted Nov 2, 2011 21:36 UTC (Wed) by quotemstr (subscriber, #45331)
I've never seen this behavior. Any decent implementation of #pragma once should not flag two files with different contents as identical. Very old compilers were sometimes confused by various links of link, but this issue hasn't cropped up in a very long time.
Please provide a pointer to a bug report or at a set of setps to demonstrate the behavior you describe.
Hmm... Very simple test...
Posted Nov 3, 2011 13:20 UTC (Thu) by khim (subscriber, #9252)
This is just a preprocessor test, but compiler does the same thing.
Note that usually we do want this behavior (these files are identical - they come from the same source, after all) - and usually it works, but sometimes when you do complex manipulations (git in my case, but of course it's not the only possibility) everything blows up.
There is always a well-known solution to every human problem--neat, plausible, and wrong.
Well, "#pragma once" is such a solution - don't use it.
Posted Nov 3, 2011 0:56 UTC (Thu) by Cyberax (✭ supporter ✭, #52523)
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds