跳轉到內容

Ada 程式設計/編譯指示/規範化標量

來自華夏公益教科書,自由的教科書

Ada. Time-tested, safe and secure.
Ada. 經時間考驗,安全可靠。

編譯指示 Normalize_Scalars 指示編譯器用可預測的值初始化未初始化的標量變數。如果可能,編譯器將選擇超出範圍的值。

pragma Normalize_Scalars;
...
My_Variable : Positive; -- Oops, forgot to initialize this variable.
                        -- The compiler (may) initialize this to 0
...
-- Oops, using a variable before it is initialized!
-- An exception should be raised here, since the compiler
-- initialized the value to 0 - an out-of-range value for the Positive type.
Some_Other_Variable := My_Variable;

華夏公益教科書

[編輯 | 編輯原始碼]
華夏公益教科書