Code: Select all
ImportC ""
errno
;sock_errno() ; macOS
EndImport
Code: Select all
ImportC ""
errno
;sock_errno() ; macOS
EndImport
Code: Select all
global errno
!v_errno = errno;
Code: Select all
;-TOP
; By mk-soft, v1.01.1, 08.01.2023
; Not work with ASM
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Macro GetLastError()
GetLastError_()
EndMacro
CompilerElse
CompilerIf #PB_Compiler_Backend = #PB_Backend_C
Procedure GetLastError()
!#include "errno.h"
!extern int errno;
Protected r1
!v_r1=errno;
ProcedureReturn r1
EndProcedure
CompilerElse
ImportC ""
errno
EndImport
;!extrn errno;
Procedure GetLastError()
Protected r1
r1 = errno
ProcedureReturn r1
EndProcedure
CompilerEndIf
CompilerEndIf
; ----
Procedure.s GetLastNetworkError()
Protected r1.s, errcode, *buffer, len
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
errcode = WSAGetLastError_()
len = FormatMessage_(#FORMAT_MESSAGE_ALLOCATE_BUFFER|#FORMAT_MESSAGE_FROM_SYSTEM|#FORMAT_MESSAGE_IGNORE_INSERTS, 0, errCode, 0, @*buffer,0,0)
If len
r1 = PeekS(*buffer)
LocalFree_(*buffer)
EndIf
CompilerDefault
*buffer = strerror_(GetLastError())
r1 = PeekS(*buffer, -1, #PB_Ascii)
CompilerEndSelect
ProcedureReturn r1
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
r1.s = GetLastNetworkError()
Debug r1
CompilerEndIf
/usr/bin/ld: errno: TLS definition in /lib/x86_64-linux-gnu/libc.so.6 section .tbss mismatches non-TLS reference in purebasic.o
/usr/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: error adding symbols: bad value
collect2: error: ld returned 1 exit status