microsoft vs. bloodshed

Started by
66 comments, last by Adam Hamilton 18 years ago
Quote:Original post by Promit

As for pragma once, there's nothing wrong with it as long as you use it and include guards together.


Then what is the point of using #pragma once if you are going to put include guards in unless your hard drive and computer are really, really slow.
Advertisement
Quote:Original post by Adam Hamilton
Quote:Original post by Promit

As for pragma once, there's nothing wrong with it as long as you use it and include guards together.


Then what is the point of using #pragma once if you are going to put include guards in unless your hard drive and computer are really, really slow.

It is possible that #pragma once will provide better performance on VS. From what I can tell, they don't advertise checking for include guards in the same way that GCC does. So you are guarenteed to only parse the file once in VS if you use #pragma once, and guarenteed to only parse the file once in GCC if you use include guards.

CM
But you missed my point entirely. I know that #pragma once yields better performance on VS compilers and include guards are treated as special on GCC but in this post by jonahrowley the performance boost would be minimal as the file is most likely cached.

Which is why I said you can drop the #pragma once and I think would be advisable for writing cross compiler code. Why bother with if/else just for the include guard when the performance gain is minimal.

But I may be wrong as I have never actually wrote a huge project and tested compile times using both the include guard method and the #pragma once method.
Quote:Original post by Adam Hamilton
But you missed my point entirely. I know that #pragma once yields better performance on VS compilers and include guards are treated as special on GCC but in this post by jonahrowley the performance boost would be minimal as the file is most likely cached.

Which is why I said you can drop the #pragma once and I think would be advisable for writing cross compiler code. Why bother with if/else just for the include guard when the performance gain is minimal.

But I may be wrong as I have never actually wrote a huge project and tested compile times using both the include guard method and the #pragma once method.

An identical argument can be used against inclusion guards. The file is probably cached, so the performance benefit is minimal. Your code will probably never be compiled on anything that uses #pragma once in an unexpected way, so the cross-platform benefit is minimal. It doesn't really matter one way or the other, but there's no reason not to use #pragma once just like there's no reason not to use #pragma comment to specify libraries. In the best case, it helps, and in the worst case it doesn't hurt.

CM
I don't know why my point isn't getting across

If you are writing cross compiler code, only use include guards.
If you don't care about targeting a multitude of compilers and you are using VS, use #pragma once

But for heavens sake. DONT put them both in. It just rings of stupidity
I use bloodshed. I tried microsoft but i get a bunch of error for a simple program such as hello world. Bloodshed works fine.
Quote:Original post by Adam Hamilton
I don't know why my point isn't getting across

If you are writing cross compiler code, only use include guards.
If you don't care about targeting a multitude of compilers and you are using VS, use #pragma once

But for heavens sake. DONT put them both in. It just rings of stupidity

Your point is getting across, you're just wrong. It isn't stupid to add both unless you are developing something like boost that absolutely, positively, has to run on as many compilers as possible without drastic changes. And even then, using both would only cause a problem on the odd compiler that uses #pragma once for something unexpected. For everybody else, using both is perfectly acceptable.

It might be a waste of time, but it hardly rings of stupidity.

CM
Quote:Original post by Adam Hamilton
But for heavens sake. DONT put them both in. It just rings of stupidity
Why not? #pragma once can never hurt you, only help, however marginally.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Maybe we should agree to disagree on this one. I have never written cross compiler code so I just use #pragma once but If I had to then I would just use the include guards

I was only trying to get across that I thought the compilation time difference between this

#ifndef __someheader_h#define __someheader_h// Check for microsoft compiler#ifdef _VISUALC#pragma once#endif// Header specific stuff#endif


and this

#ifndef __someheader_h#define __someheader_h// Header specific stuff#endif


would maybe add seconds to a compilation time of a large project and to me that would not justify the use of a second check to shave maybe <10ms from an individual .cpp compilation time.

I shouldn't have said rings of stupidity, I was just really frustrated so I apologise if i may have offended anyone.
Quote:Original post by Adam Hamilton
I have never written cross compiler code...

Then perhaps you should stop trying to speak authoritatively about it?

This topic is closed to new replies.

Advertisement