Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Usually, when someone in closed-source land has a really good idea and implements it well, the folks in open-source land try and replicate it to the best of their ability. .NET? Mono. Photoshop? GIMP. Mac OS? GNOME. So why is it that only Microsoft compilers support #pragma once? Did Microsoft patent it or something? Or did the open-source community actually come to the consensus that #ifdef MYHEADER_H #define MYHEADER_H /* mycode */ #endif is somehow better? Not trying to troll here, just genuinely curious!
Posted
Comments
Sergey Alexandrovich Kryukov 27-Sep-12 19:44pm    
I'm am risking to spark a flame war, but I have just one answer:

--"Barrymore, what's going on with "#pragma once"? It is supported or not? And why?"
--"Morons, Sir..."

C++ world is so dirty. And who is responsible?.. I cannot stop wondering, how it's possible to have, in XXI century, such archaic architecture of modularity as the one based on "#include" and object files linked by the names of symbols. Stone age. No, even when C++ was introduced, it was already stone age, because most of the things were already discovered...
--SA
Sergey Alexandrovich Kryukov 27-Sep-12 19:54pm    
And let me say that I understand your concerns and really appreciate your curiosity and critical thinking. I voted 5 for the question.
--SA

1 solution

This is basically what it is:
http://en.wikipedia.org/wiki/Pragma_once[^].

It does not say it's only Microsoft, it's "non-standard but widely supported". The argument that C++ is ISO standard makes me Laugh Out Loud.
In my opinion, the problem is not "#once", the problem is "#ever" :-). We still have "#include", in XXI century — my congratulations, Ladies and Gentlemen.

Thanks goodness, I had enough alternatives even in the world of native-platform programming and in lowest level.

—SA
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 27-Sep-12 20:11pm    
Oh, first down-votes coming up! C++ fans do not forgive the truth... :-)
No matter, we have many members who really know C++ and use it well, not the fans but qualified users.
--SA
JackDingler 28-Sep-12 17:44pm    
I've thought along similar lines for most of my career.

I have the view that the notion of files is archaic in writing code.

The typical naysayer to this notion often replies, "Oh we tried that and it had problems." As if file systems never suffer from "problems".
Sergey Alexandrovich Kryukov 28-Sep-12 19:01pm    
Thank you, Jack,

Your humor is based on some the grain of truth, but I think you perfectly understand that those things are different. Programming process is agnostic the nature of the file system, the file system is agnostic to its use, archaic or not. In contrast, #include and related archaic stuff presents the sticky binding between programming and its environment. In programming systems without such stuff as #include (invented so many years ago), the binding is loose: the code works with some "modules" (packages, compilations units, assemblies...) abstracted from the files, and binding between logical and units is defined by the environment. And this environment could be as simple as make file... Everything is properly layered. No idiotic bugs related to mere order of includes, if not worse...
--SA
JackDingler 28-Sep-12 19:08pm    
Actually, I wasn't joking.

'Files', are simply a traditional container for keeping code organized.
Objects are an abstract idea that is anchored into C++, in files.

These objects could be represented in a different form. Perhaps a system grounded in a database. In this view you could attach more attributes to code and perhaps make a system that is by nature more portable among disparate systems.

We're accustomed to coding being in the form it is, because it's the way it's always been done.
Sergey Alexandrovich Kryukov 28-Sep-12 19:26pm    
Exactly, and this binding is evil. It's enough to compare these different approaches to see.
And who is accustomed to files? This is the question.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900