仕様書 http://www.open-std.org/jtc1/sc22/wg14/www/standards [open-std.org] ここの WG14 N1570 を読んでみました。確かに >5.1.2.2.1 Program startup >It shall be defined with a return type of int とも書いてあるんですが、最後に >or in some other implementation-defined manner. と書いてひっくり返してあります。そんなわけで言語仕様上は、 #2638323 に tenokida さんが書かれているように、 実装依存という
The rationale for the C99 standard [open-std.org]の5.1.2.2.1を見ると、 そのsome other implementation-defined mannerってのは、おそらく引数の事で、戻り値の型では無いと思う。
While many implementations support more than two arguments to main, such practice is neither blessed nor forbidden by the Standard; a program that defines main with three arguments is not strictly conforming.
アルゴリズムのお勉強 (スコア:0)
コンピュータサイエンスの初級コースってのが
どんな教育をする場かは知りませんが、
アルゴリズムのお勉強とかは、C/C++ がベストと思うんですよね。
使える機能がもっとも原始的という意味で。
ま、最低、Java でもいいとは思うけど。
Re: (スコア:0)
初級ならお約束は少ない方がいいんじゃないでしょうか
Cだといきなり
#include <stdio.h>
とか(当初は)意味不明なお約束が出てきて
「へ~、スタジオをインクルードっと。あれ、エラー? stANDARd iNPUT/oUTPUT? 騙された!」
となるわけでそれだけで嫌いになる要素充分ですわ
Re: (スコア:0)
あとvoid main~も。
Re:アルゴリズムのお勉強 (スコア:0)
あとvoid main~も。
とまあ、かように間違える人が引きも切らないわけで
#誤:void main 正:int main
##理由:言語仕様で決まっているから
Re:アルゴリズムのお勉強 (スコア:2)
hosted environmentだっけか、ランタイムに対する仕様
ランタイムまで自作するときにゃvoid main(void)でもかまわん、
つまり言語そのものの仕様とはしないってのがCの特徴では?
Re: (スコア:0)
言語オタクや老害になるとこのように初級者にいきなりそういうことを体験させるのが適切かという観点がすっぽりと抜け落ちます。
Re: (スコア:0)
まずレッテルから入る反論は心弱さの表れ
Re: (スコア:0)
すみません
(#2638323)がただのバカだという観点がすっぽり落ちてました
Re: (スコア:0)
仕様書
http://www.open-std.org/jtc1/sc22/wg14/www/standards [open-std.org]
ここの WG14 N1570 を読んでみました。確かに
>5.1.2.2.1 Program startup
>It shall be defined with a return type of int
とも書いてあるんですが、最後に
>or in some other implementation-defined manner.
と書いてひっくり返してあります。そんなわけで言語仕様上は、
#2638323 に tenokida さんが書かれているように、
実装依存という
Re: (スコア:0)
The rationale for the C99 standard [open-std.org]の5.1.2.2.1を見ると、
そのsome other implementation-defined mannerってのは、おそらく引数の事で、戻り値の型では無いと思う。
While many implementations support more than two arguments to main, such practice is neither blessed nor forbidden by the Standard; a program that defines main with three arguments is not strictly conforming.
Re: (スコア:0)
補足すると、Freestandingに関しては5.1.2.1に述べてあるように全く自由で、関数名も何も決められてない。
だからmainを関数名として使っても良いけど、それはHostedのmainとは無関係。
5.1.2.2(と5.1.2.2.1)はHostedの話で、この場合戻り値の型はintと決まっている。
Re: (スコア:0)
http://c-faq.com/ansi/voidmain.html [c-faq.com]