C 標準函式庫
Base.Libc.malloc
— 函式malloc(size::Integer) -> Ptr{Cvoid}
呼叫 C 標準函式庫中的 malloc
。
Base.Libc.calloc
— 函式calloc(num::Integer, size::Integer) -> Ptr{Cvoid}
呼叫 C 標準函式庫中的 calloc
。
Base.Libc.realloc
— 函式realloc(addr::Ptr, size::Integer) -> Ptr{Cvoid}
呼叫 C 標準函式庫中的 realloc
。
Base.memcpy
— 函數memcpy(dst::Ptr, src::Ptr, n::Integer) -> Ptr{Cvoid}
呼叫 C 標準函式庫中的 memcpy
。
支援 memcpy
至少需要 Julia 1.10。
Base.memmove
— 函數memmove(dst::Ptr, src::Ptr, n::Integer) -> Ptr{Cvoid}
呼叫 C 標準函式庫中的 memmove
。
支援 memmove
至少需要 Julia 1.10。
Base.memset
— 函數memset(dst::Ptr, val, n::Integer) -> Ptr{Cvoid}
呼叫 C 標準函式庫中的 memset
。
支援 memset
至少需要 Julia 1.10。
Base.memcmp
— 函數memcmp(a::Ptr, b::Ptr, n::Integer) -> Int
呼叫 C 標準函式庫中的 memcmp
。
支援 memcmp
至少需要 Julia 1.9。
Base.Libc.free
— 函數free(addr::Ptr)
呼叫 C 標準函式庫中的 free
。僅對從 malloc
取得的記憶體使用此函數,不要對從其他 C 函式庫取得的指標使用。從 C 函式庫取得的 Ptr
物件應由該函式庫中定義的 free 函數釋放,以避免在系統中存在多個 libc
函式庫時發生斷言失敗。
Base.Libc.errno
— 函數errno([code])
取得 C 函式庫的 errno
值。如果指定引數,則用來設定 errno
的值。
errno
的值僅在對設定它的 C 函式庫常式執行 ccall
之後才有效。具體來說,您無法在 REPL 中的下一提示字元呼叫 errno
,因為在提示字元之間執行了大量程式碼。
Base.Libc.strerror
— 函數strerror(n=errno())
將系統呼叫錯誤碼轉換為描述性字串
Base.Libc.GetLastError
— 函數GetLastError()
呼叫 Win32 GetLastError
函數 [僅在 Windows 上可用]。
Base.Libc.FormatMessage
— 函數FormatMessage(n=GetLastError())
將 Win32 系統呼叫錯誤碼轉換為描述性字串 [僅在 Windows 上可用]。
Base.Libc.time
— 方法time(t::TmStruct) -> Float64
將 TmStruct
結構轉換為自紀元以來的秒數。
Base.Libc.strftime
— 函數strftime([format], time)
將時間(以自紀元以來的秒數或 TmStruct
表示)轉換為使用指定格式的格式化字串。支援的格式與標準 C 函式庫中的格式相同。
Base.Libc.strptime
— 函數strptime([format], timestr)
將格式化時間字串解析為 TmStruct
,提供秒、分、時、日期等。支援的格式與標準 C 函式庫中的格式相同。在某些平台上,時區無法正確解析。如果此函數的結果將傳遞給 time
以將其轉換為自紀元以來的秒數,則應手動填寫 isdst
欄位。將其設定為 -1
將告知 C 函式庫使用目前的系統設定來判斷時區。
Base.Libc.TmStruct
— 類型TmStruct([seconds])
將自紀元以來的秒數轉換為分解格式,欄位包括 sec
、min
、hour
、mday
、month
、year
、wday
、yday
和 isdst
。
Base.Libc.flush_cstdio
— 函數flush_cstdio()
沖刷 C stdout
和 stderr
串流(可能已由外部 C 程式碼寫入)。
Base.Libc.systemsleep
— 函數