Customizing the Arguments of main in C
The default signatures for main in C are well-known: int main() and int main(int, char*[]). However, a question arises:
Can main's arguments be modified with qualifiers like unsigned and const?
My tests indicate yes, but concerns remain about potential overloading or violation of C standards.
According to the C 98 standard (section 3.6.1 paragraph 2), overloading main is prohibited. The standard explicitly states that main must have a return type of int, but its other aspects are implementation-defined.
Notably, the standard does not forbid the use of arguments with qualifiers like unsigned and const. While it is not mandated by the standard, it is permissible for implementations to accept these modifications.
Freestanding environments, where startup and termination behaviors are implementation-defined, are exempt from these rules and documentation may detail specific behaviors.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3