Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C compiler
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 27-Sep-12 14:11pm
ekolis3.6K
Comments
Sergey Alexandrovich Kryukov at 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 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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" Smile | :) . 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
  Permalink  
v3
Comments
Sergey Alexandrovich Kryukov at 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 at 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 at 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 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 195
3 DamithSL 195
4 Richard MacCutchan 178
0 OriginalGriff 5,130
1 DamithSL 4,197
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 27 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100