and. Is the following attempt valid for determining the entry point of a "main" stand-alone C ++ program?
namespace{ extern int main(){return 0;} }
As far as I understand, it satisfies all the criteria of "main" in the C ++ standard (external communication available in the global namespace due to the implicit usage directive).
So this program is poorly formed and why? Any reference to the standard?
Q. I went through discussions on EXIT_FAILURE and EXIT_SUCCESS, but could not complete if EXIT_SUCCESS should always be 0. This is because, according to the standard leaving the return statement in "main", returning 0 is equivalent. So, I think, EXIT_SUCCESS must always be 0.
$ 18.3 - "If the status is zero or EXIT_SUCCESS, a form is returned that defines the implementation, successful completion of the state."
No. The C ++ standard states: “A program must contain a global function called main” (§3.6.1 / 1). In your program, a function is mainnot part of the global namespace; it is in an unnamed namespace.
main
; . , " using - , " (§7.3.4/1).
?
. main , ; main. namespace { int main(); } int main() - , .
namespace { int main(); }
int main()
, main , (, , ).
. dicussions EXIT_FAILURE EXIT_SUCCESS, , EXIT_SUCCESS 0.
EXIT_FAILURE
EXIT_SUCCESS
0
, EXIT_SUCCESS 0. C , <stdlib.h>,
<stdlib.h>
... EXIT_FAILURE EXIT_SUCCESS, , exit , , (C99 §7.20/3).
exit
( <cstdlib>, C ).
<cstdlib>
namespace { } - , - -, . extern, extern "C", , main , , . , - , . , , :-). - ? - ?
namespace { }
extern
extern "C"
, EXIT_SUCCESS EXIT_FAILURE. , main exit() , . 0 , EXIT_SUCCESS, 0 "". 0 ... , , "" . - , 0, - , . - : (, Linux) , 8 , 256 0. , 0.
. Visual ++ 2010, :
1 LNK1561:
++ main (,:: main) ( ), () - , .
, , C : EXIT_SUCCESS ( ) EXIT_FAILURE. .
.
Source: https://habr.com/ru/post/1763713/More articles:Which cmdlets use the IHostUISupportsMultipleChoiceSelection interface to request a selection? - interfaceMacOSX открыть файл с приложением: куда он идет? - macosHaxe - Встраивать файлы, как в ActionScript? - actionscript-3Check: inclusion in rails based on the parent value of the model attribute - validationResource presentation pregeneration - restDifferences browser jQuery.val () - jqueryJQuery - Detect CSS display support: table-row-group '- javascriptproposals for initial import and project verification - version-controlUINavigationBar disappears using UISearchBar and SearchDisplayController - iphoneFull-text search database example - full-text-searchAll Articles