Isn't the note below a contradiction in relation to paragraphs (2.1) and (2.2) in [basic.start.main]/2?












-2














[basic.start.main]/2:




An implementation shall not predefine the main function. This function
shall not be overloaded. Its type shall have C++ language linkage and
it shall have a declared return type of type int, but otherwise its
type is implementation-defined. An implementation shall allow both



(2.1) a function of () returning int and

(2.2) a function of (int, pointer to pointer to char) returning int



as the type of main
([dcl.fct]). In the latter form, for purposes of exposition, the first
function parameter is called argc and the second function parameter is
called argv, where argc shall be the number of arguments passed to the
program from the environment in which the program is run. If argc is
nonzero these arguments shall be supplied in argv[0] through
argv[argc-1] as pointers to the initial characters of null-terminated
multibyte strings (NTMBSS) ([multibyte.strings]) and argv[0] shall be
the pointer to the initial character of a NTMBS that represents the
name used to invoke the program or "". The value of argc shall be
non-negative. The value of argv[argc] shall be 0. [ Note: It is
recommended that any further (optional) parameters be added after
argv. — end note
 ]











share|improve this question


















  • 2




    It says an implementation shall allow both, but not only both.
    – Neil Butterworth
    Nov 23 '18 at 18:56






  • 2




    Why do you feel this is a contradiction?
    – Nicol Bolas
    Nov 23 '18 at 18:57






  • 1




    Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
    – user10605163
    Nov 23 '18 at 18:59


















-2














[basic.start.main]/2:




An implementation shall not predefine the main function. This function
shall not be overloaded. Its type shall have C++ language linkage and
it shall have a declared return type of type int, but otherwise its
type is implementation-defined. An implementation shall allow both



(2.1) a function of () returning int and

(2.2) a function of (int, pointer to pointer to char) returning int



as the type of main
([dcl.fct]). In the latter form, for purposes of exposition, the first
function parameter is called argc and the second function parameter is
called argv, where argc shall be the number of arguments passed to the
program from the environment in which the program is run. If argc is
nonzero these arguments shall be supplied in argv[0] through
argv[argc-1] as pointers to the initial characters of null-terminated
multibyte strings (NTMBSS) ([multibyte.strings]) and argv[0] shall be
the pointer to the initial character of a NTMBS that represents the
name used to invoke the program or "". The value of argc shall be
non-negative. The value of argv[argc] shall be 0. [ Note: It is
recommended that any further (optional) parameters be added after
argv. — end note
 ]











share|improve this question


















  • 2




    It says an implementation shall allow both, but not only both.
    – Neil Butterworth
    Nov 23 '18 at 18:56






  • 2




    Why do you feel this is a contradiction?
    – Nicol Bolas
    Nov 23 '18 at 18:57






  • 1




    Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
    – user10605163
    Nov 23 '18 at 18:59
















-2












-2








-2







[basic.start.main]/2:




An implementation shall not predefine the main function. This function
shall not be overloaded. Its type shall have C++ language linkage and
it shall have a declared return type of type int, but otherwise its
type is implementation-defined. An implementation shall allow both



(2.1) a function of () returning int and

(2.2) a function of (int, pointer to pointer to char) returning int



as the type of main
([dcl.fct]). In the latter form, for purposes of exposition, the first
function parameter is called argc and the second function parameter is
called argv, where argc shall be the number of arguments passed to the
program from the environment in which the program is run. If argc is
nonzero these arguments shall be supplied in argv[0] through
argv[argc-1] as pointers to the initial characters of null-terminated
multibyte strings (NTMBSS) ([multibyte.strings]) and argv[0] shall be
the pointer to the initial character of a NTMBS that represents the
name used to invoke the program or "". The value of argc shall be
non-negative. The value of argv[argc] shall be 0. [ Note: It is
recommended that any further (optional) parameters be added after
argv. — end note
 ]











share|improve this question













[basic.start.main]/2:




An implementation shall not predefine the main function. This function
shall not be overloaded. Its type shall have C++ language linkage and
it shall have a declared return type of type int, but otherwise its
type is implementation-defined. An implementation shall allow both



(2.1) a function of () returning int and

(2.2) a function of (int, pointer to pointer to char) returning int



as the type of main
([dcl.fct]). In the latter form, for purposes of exposition, the first
function parameter is called argc and the second function parameter is
called argv, where argc shall be the number of arguments passed to the
program from the environment in which the program is run. If argc is
nonzero these arguments shall be supplied in argv[0] through
argv[argc-1] as pointers to the initial characters of null-terminated
multibyte strings (NTMBSS) ([multibyte.strings]) and argv[0] shall be
the pointer to the initial character of a NTMBS that represents the
name used to invoke the program or "". The value of argc shall be
non-negative. The value of argv[argc] shall be 0. [ Note: It is
recommended that any further (optional) parameters be added after
argv. — end note
 ]








c++ language-lawyer






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 18:52









WaldBWaldB

476311




476311








  • 2




    It says an implementation shall allow both, but not only both.
    – Neil Butterworth
    Nov 23 '18 at 18:56






  • 2




    Why do you feel this is a contradiction?
    – Nicol Bolas
    Nov 23 '18 at 18:57






  • 1




    Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
    – user10605163
    Nov 23 '18 at 18:59
















  • 2




    It says an implementation shall allow both, but not only both.
    – Neil Butterworth
    Nov 23 '18 at 18:56






  • 2




    Why do you feel this is a contradiction?
    – Nicol Bolas
    Nov 23 '18 at 18:57






  • 1




    Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
    – user10605163
    Nov 23 '18 at 18:59










2




2




It says an implementation shall allow both, but not only both.
– Neil Butterworth
Nov 23 '18 at 18:56




It says an implementation shall allow both, but not only both.
– Neil Butterworth
Nov 23 '18 at 18:56




2




2




Why do you feel this is a contradiction?
– Nicol Bolas
Nov 23 '18 at 18:57




Why do you feel this is a contradiction?
– Nicol Bolas
Nov 23 '18 at 18:57




1




1




Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
– user10605163
Nov 23 '18 at 18:59






Please specify what exactly you consider the contradiction. It is not clear to me how you interpret the mentioned parts of the quote.
– user10605163
Nov 23 '18 at 18:59














1 Answer
1






active

oldest

votes


















2














It states that at least two signatures must be permitted; int main() and int main(int, char**).



What other types are permitted is implementation-defined.



They recommend that if your implementation permits main with more arguments, that they be added after the int, char** arguments of that particular signature. This is not forced.



The implementation could say that this is a valid main signature:



int main( std::vector<std::string> args )


or it could have:



int main( int, char**, system::permission_token )


or whatever.



This second one -- the system::permission_token -- where that is an optional argument (ie, int main(int, char**) still works), would be what the note advises. The first style is still permitted.






share|improve this answer





















  • The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
    – WaldB
    Nov 23 '18 at 19:12










  • @WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. All main functions must return int (part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
    – Yakk - Adam Nevraumont
    Nov 23 '18 at 19:14












  • I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
    – WaldB
    Nov 23 '18 at 19:26










  • @WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
    – Yakk - Adam Nevraumont
    Nov 23 '18 at 19:37










  • Could you comment on this specific meaning?
    – WaldB
    Nov 23 '18 at 19:56











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451711%2fisnt-the-note-below-a-contradiction-in-relation-to-paragraphs-2-1-and-2-2-i%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














It states that at least two signatures must be permitted; int main() and int main(int, char**).



What other types are permitted is implementation-defined.



They recommend that if your implementation permits main with more arguments, that they be added after the int, char** arguments of that particular signature. This is not forced.



The implementation could say that this is a valid main signature:



int main( std::vector<std::string> args )


or it could have:



int main( int, char**, system::permission_token )


or whatever.



This second one -- the system::permission_token -- where that is an optional argument (ie, int main(int, char**) still works), would be what the note advises. The first style is still permitted.






share|improve this answer





















  • The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
    – WaldB
    Nov 23 '18 at 19:12










  • @WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. All main functions must return int (part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
    – Yakk - Adam Nevraumont
    Nov 23 '18 at 19:14












  • I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
    – WaldB
    Nov 23 '18 at 19:26










  • @WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
    – Yakk - Adam Nevraumont
    Nov 23 '18 at 19:37










  • Could you comment on this specific meaning?
    – WaldB
    Nov 23 '18 at 19:56
















2














It states that at least two signatures must be permitted; int main() and int main(int, char**).



What other types are permitted is implementation-defined.



They recommend that if your implementation permits main with more arguments, that they be added after the int, char** arguments of that particular signature. This is not forced.



The implementation could say that this is a valid main signature:



int main( std::vector<std::string> args )


or it could have:



int main( int, char**, system::permission_token )


or whatever.



This second one -- the system::permission_token -- where that is an optional argument (ie, int main(int, char**) still works), would be what the note advises. The first style is still permitted.






share|improve this answer





















  • The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
    – WaldB
    Nov 23 '18 at 19:12










  • @WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. All main functions must return int (part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
    – Yakk - Adam Nevraumont
    Nov 23 '18 at 19:14












  • I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
    – WaldB
    Nov 23 '18 at 19:26










  • @WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
    – Yakk - Adam Nevraumont
    Nov 23 '18 at 19:37










  • Could you comment on this specific meaning?
    – WaldB
    Nov 23 '18 at 19:56














2












2








2






It states that at least two signatures must be permitted; int main() and int main(int, char**).



What other types are permitted is implementation-defined.



They recommend that if your implementation permits main with more arguments, that they be added after the int, char** arguments of that particular signature. This is not forced.



The implementation could say that this is a valid main signature:



int main( std::vector<std::string> args )


or it could have:



int main( int, char**, system::permission_token )


or whatever.



This second one -- the system::permission_token -- where that is an optional argument (ie, int main(int, char**) still works), would be what the note advises. The first style is still permitted.






share|improve this answer












It states that at least two signatures must be permitted; int main() and int main(int, char**).



What other types are permitted is implementation-defined.



They recommend that if your implementation permits main with more arguments, that they be added after the int, char** arguments of that particular signature. This is not forced.



The implementation could say that this is a valid main signature:



int main( std::vector<std::string> args )


or it could have:



int main( int, char**, system::permission_token )


or whatever.



This second one -- the system::permission_token -- where that is an optional argument (ie, int main(int, char**) still works), would be what the note advises. The first style is still permitted.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 18:56









Yakk - Adam NevraumontYakk - Adam Nevraumont

183k19189374




183k19189374












  • The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
    – WaldB
    Nov 23 '18 at 19:12










  • @WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. All main functions must return int (part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
    – Yakk - Adam Nevraumont
    Nov 23 '18 at 19:14












  • I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
    – WaldB
    Nov 23 '18 at 19:26










  • @WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
    – Yakk - Adam Nevraumont
    Nov 23 '18 at 19:37










  • Could you comment on this specific meaning?
    – WaldB
    Nov 23 '18 at 19:56


















  • The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
    – WaldB
    Nov 23 '18 at 19:12










  • @WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. All main functions must return int (part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
    – Yakk - Adam Nevraumont
    Nov 23 '18 at 19:14












  • I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
    – WaldB
    Nov 23 '18 at 19:26










  • @WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
    – Yakk - Adam Nevraumont
    Nov 23 '18 at 19:37










  • Could you comment on this specific meaning?
    – WaldB
    Nov 23 '18 at 19:56
















The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
– WaldB
Nov 23 '18 at 19:12




The quote "but otherwise its type is implementation-defined" could very well refer to the return type of the function, and not to other arguments. At least that was my interpretation.
– WaldB
Nov 23 '18 at 19:12












@WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. All main functions must return int (part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:14






@WaldB Sure, you misread it. The but clause does not remove the "shall" requirement from the first part of the phrase. The type of a function includes its return value, its arguments, and (in later versions of C++) if it is noexcept. All main functions must return int (part 1 of sentence), but everything else is implementation defined about its type (part 2 of the sentence). It then goes on to further restrict what the implemenation can define (saying it must support two different signatures, without limiting it to supporting those two).
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:14














I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
– WaldB
Nov 23 '18 at 19:26




I would say that your previous comment makes sense to me. But I don't agree that anyone (including native English speakers) could arrive at this conclusion, just by reading the standard.
– WaldB
Nov 23 '18 at 19:26












@WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:37




@WaldB Probably the fact that "shall" has a very specific meaning in ISO standards might have tripped you up.
– Yakk - Adam Nevraumont
Nov 23 '18 at 19:37












Could you comment on this specific meaning?
– WaldB
Nov 23 '18 at 19:56




Could you comment on this specific meaning?
– WaldB
Nov 23 '18 at 19:56


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451711%2fisnt-the-note-below-a-contradiction-in-relation-to-paragraphs-2-1-and-2-2-i%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Lallio

Unable to find Lightning Node

Futebolista