LinuxC库版本探究(linuxc库版本)

Linux C 库(libc)是 Linux 系统中的一个关键组件,为 C 语言程序员提供了许多程序开发的基础功能。它负责与系统内核交互,提供对文件、进程、网络通信等 I/O 操作的支持,同时也提供了各种数据结构和算法库。随着时间的推移,Linux C 库迭代发展,不断提升性能和支持新的功能。本文将介绍 Linux C 库的版本演变、特点和使用中需要注意的问题。

创新互联网站建设服务商,为中小企业提供做网站、成都网站设计服务,网站设计,网站托管运营等一站式综合服务型公司,专业打造企业形象网站,让您在众多竞争对手中脱颖而出创新互联。

linux c 库版本演变

最早的 Linux 系统采用的是 Minix libc,该库是 Minix 操作系统的一个变种。Linux 0.01 发布时,仅自带源代码,用户可以自行编译安装 C 库。时至今日,Linux C 库已经经历了多个版本的演变,其中最为知名的版本是 Glibc(GNU libc)。

Glibc 是基于 GNU 项目的开源 C 库,由红帽公司维护。该库作为现代 Linux 系统的标准 C 库,具有广泛的应用。Glibc 最早发布于 1992 年,至今已经更新到了版本 2.33。Glibc 2.0 在 1997 年发布,它的特点是提供完整的国际化方式,支持多语言字符集和本地化,使得 Linux 可以用于全球范围内的应用程序开发。此后,Glibc 2.x 系列迭代加入了许多新特性,包括线程安全、初始程序加载器(dynamic linker)和调试支持等。

除了 Glibc 外,还有其他的 C 库版本,比如 uClibc、Musl libc 等。uClibc 最初是为嵌入式系统开发设计的 C 库,它的特点是占用较少的内存,适合在资源匮乏的设备上运行。Musl libc 是一个轻量级的 C 库,主要与其他 Linux 系统兼容,但与 Glibc 比较,Musl libc 的体积更小,启动速度更快,并且支持静态链接。

Linux C 库的特点

Linux C 库是一个重要的系统组件,它有以下几个特点:

1.提供了 C 语言开发的基础支持

Linux C 库为 C 语言开发提供了标准的 I/O、内存管理、文件操作、进程管理等基础功能,大大降低了开发者的工作量,提高了生产效率。

2.与系统内核紧密配合

Linux C 库是用户空间与内核空间之间的桥梁,负责将用户程序的请求转换为系统调用传递给内核,同时将内核返回的结果转化为可读写的格式返回给用户程序。因此 Linux C 库与内核的版本需要保持一致。

3.对多线程程序提供支持

随着多核心处理器的普及,支持多线程的程序越来越受到关注。Linux C 库提供了多线程编程的接口和相关函数,支持线程同步和互斥,保障了多线程程序的可靠性。

4.具有良好的扩展性

Linux C 库是开源软件,它可以被自由地修改和扩展。用户可以根据需要在库中添加自己的函数和接口,以适应自己的应用需求。

Linux C 库的使用注意事项

虽然 Linux C 库为开发者提供了许多便捷的功能和接口,但在使用过程中还有一些需要注意的问题。下面是一些常见的注意事项:

1.版本问题

Linux C 库与系统内核密切相关,用户应该根据系统内核版本来选择对应的 C 库版本。如果版本不匹配,可能会导致程序异常或崩溃。

2.动态链接和静态链接

Linux C 库的链接方式有两种:动态链接和静态链接。动态链接是在运行时将库文件载入内存,并与程序动态链接。静态链接则是将库文件编译进可执行程序中。动态链接的优点是共享库,可以减少内存的使用,但也有一定的安全风险。静态链接的优点是程序独立运行,可移植性好,但会增加可执行程序的大小和编译时间。

3.编译选项

Linux C 库的编译选项非常丰富,包括优化选项、调试选项、安全选项等。用户应该根据自己的需求选择适当的编译选项,以确保程序的性能和安全性。

结论

Linux C 库是一个关键的系统组件,它为 C 语言程序员提供了许多基础功能和接口。常见的 Linux C 库版本有 Glibc、uClibc、Musl libc 等,它们具有不同的特点和优缺点。在使用 Linux C 库时,用户需要注意版本问题、链接方式、编译选项等问题,以确保程序的正确性、可靠性和性能。

成都网站建设公司-创新互联为您提供网站建设、网站制作、网页设计及定制高端网站建设服务!

求Linux c版 ini文件解析 库或者代码

下面是一个VB6的类的源代码,来自国外网站的一个技术专家,类名:CSetting,可以读写ini配置文件,或者卖行卖读写注册表配带掘置。

Option Explicit

‘Settings interface class

‘Copyright ?Stan Schultes

‘Written for VBPJ Getting Started September, 2023

‘CSetting mode enum

Public Enum csModes

csModeRegistry = 0

csModeINI = 1

End Enum

‘class member variables

Private m_eSaveMode As csModes

‘module-level variables

Private msININame As String’name of .INI file

Private msAppName As String’app name for settings

‘INI setting APIs

Private Declare Function GetPrivateProfileInt Lib “kernel32” Alias “GetPrivateProfileIntA” (ByVal SectionName As String, ByVal KeyName As String, ByVal Default As Long, ByVal FileName As String) As Long

Private Declare Function GetPrivateProfileString Lib “kernel32” Alias “中逗GetPrivateProfileStringA” (ByVal SectionName As String, ByVal KeyName As String, ByVal Default As String, ByVal ReturnedString As String, ByVal StringSize As Long, ByVal FileName As String) As Long

Private Declare Function WritePrivateProfileString Lib “kernel32” Alias “WritePrivateProfileStringA” (ByVal SectionName As String, ByVal KeyName As String, ByVal KeyValue As String, ByVal FileName As String) As Long

‘there is no WritePrivateProfileInt declaration…

‘Error definitions

Private Const mklErrOffset As Long = vbObjectError + 512

Private Const mklErrNotNumeric As Long = mklErrOffset + 1

Private Const mksErrNotNumeric As String = “The setting value returned was not numeric”

Private Const mklErrWriting As Long = mklErrOffset + 2

Private Const mksErrWriting As String = “Error writing Setting “

Private Const mklErrReading As Long = mklErrOffset + 3

Private Const mksErrReading As String = “Error reading Setting “

Public Function Init(Optional ByVal AppPath As String, Optional ByVal AppName As Variant, Optional ByVal Mode As csModes = csModeRegistry)

‘Set up class variables, default to Registry mode

If IsMissing(AppPath) Then

msININame = App.Path

Else

msININame = Trim$(AppPath)

End If

If IsMissing(AppName) Then

msAppName = App.EXEName

Else

msAppName = Trim$(AppName)

End If

‘default to the app’s .exe path

msININame = msININame & “\” & msAppName & “.ini”

‘ msININame = App.Path & “\” & msAppName & “.ini”

SaveMode = Mode

End Function

Public Function GetSettingStr(ByVal Section As String, ByVal KeyName As String, ByVal DefaultValue As String) As String

‘returns a string setting

Dim lRet As Long

Dim sBuf As String * 128

On Error GoTo GetSettingStr_Error

If Len(msAppName) = 0 Then Init

Select Case m_eSaveMode

Case csModeRegistry

GetSettingStr = GetSetting(msAppName, Section, KeyName, DefaultValue)

Case Else

lRet = GetPrivateProfileString(Section, KeyName, DefaultValue, sBuf, Len(sBuf), msININame)

GetSettingStr = TrimNull(sBuf)

End Select

GetSettingStr_Exit:

Exit Function

GetSettingStr_Error:

Err.Raise mklErrReading, “CSetting.GetSettingStr”, mksErrReading & “(” & Err & “, ” & Error & “)”

End Function

Public Function GetSettingInt(ByVal Section As String, ByVal KeyName As String, ByVal DefaultValue As Integer) As Integer

‘returns a numeric setting

Dim sSetting As String

On Error GoTo GetSettingInt_Error

If Len(msAppName) = 0 Then Init

Select Case m_eSaveMode

Case csModeRegistry

sSetting = GetSetting(msAppName, Section, KeyName, CStr(DefaultValue))

‘check if value is numeric

If IsNumeric(sSetting) Then

GetSettingInt = CInt(sSetting)

Else

‘match behavior of .INI return

GetSettingInt = 0

‘or – return error if desired

‘On Error GoTo’disable handler to return error

‘Err.Raise mklErrNotNumeric, “CSetting.GetSettingInt”, mksErrNotNumeric

End If

Case Else

‘returns 0 if not numeric

GetSettingInt = GetPrivateProfileInt(Section, KeyName, DefaultValue, msININame)

End Select

GetSettingInt_Exit:

Exit Function

GetSettingInt_Error:

Err.Raise mklErrReading, “CSetting.GetSettingInt”, mksErrReading & “(” & Err & “, ” & Error & “)”

End Function

Public Sub SaveSettingStr(ByVal Section As String, ByVal KeyName As String, ByVal Setting As String)

‘saves a string setting

Dim lRet As Long

On Error GoTo SaveSettingStr_Error

If Len(msAppName) = 0 Then Init

Select Case m_eSaveMode

Case csModeRegistry

SaveSetting msAppName, Section, KeyName, Setting

Case Else

lRet = WritePrivateProfileString(Section, KeyName, Setting, msININame)

End Select

SaveSettingStr_Exit:

Exit Sub

SaveSettingStr_Error:

Err.Raise mklErrWriting, “CSetting.SaveSettingStr”, mksErrWriting & “(” & Err & “, ” & Error & “)”

End Sub

Public Sub SaveSettingInt(ByVal Section As String, ByVal KeyName As String, Setting As Integer)

‘saves a numeric setting

Dim lRet As Long

On Error GoTo SaveSettingInt_Error

If Len(msAppName) = 0 Then Init

Select Case m_eSaveMode

Case csModeRegistry

SaveSetting msAppName, Section, KeyName, CStr(Setting)

Case Else

lRet = WritePrivateProfileString(Section, KeyName, CStr(Setting), msININame)

End Select

SaveSettingInt_Exit:

Exit Sub

SaveSettingInt_Error:

Err.Raise mklErrWriting, “CSetting.SaveSettingInt”, mksErrWriting & “(” & Err & “, ” & Error & “)”

End Sub

Public Property Let SaveMode(Mode As csModes)

‘sets save mode, see csModes enum

m_eSaveMode = Mode

End Property

Public Property Get SaveMode() As Long

‘returns save mode

SaveMode = CLng(m_eSaveMode)

End Property

Private Function TrimNull(ByVal InString As String) As String

‘trims string at first Null character

Dim lPos As Long

TrimNull = Trim$(InString)

lPos = InStr(TrimNull, vbNullChar)

If lPos > 0 Then TrimNull = Left$(TrimNull, lPos – 1)

End Function

Private Sub Class_Initialize()

msININame = App.Path & “\” & App.EXEName & “.ini”

End Sub

使用方法:

在程序的全局模块中定义CSetting的类实例变量:(以下定义了两个,分别读写ini和注册表)

Public SetIni As CSetting ‘读写ini配置文件参数’

Public SetReg As CSetting’读写注册表配置参数

在sub main 中初始化:(其中PATH_EXE是你的程序路径,放ini文件的路径)

Set SetIni = New CSetting

SetIni.Init PATH_Exe, App.Title, csModeINI

Set SetReg = New CSetting

SetReg.Init PATH_Exe, App.Title, csModeRegistry

这就可以随便用了。

dbPassword = SetIni.GetSettingStr(NameDB, “Password”, “111111”)

dbUserID = SetIni.GetSettingStr(NameDB, “UserID”, “123456”)

dbCatalog = SetIni.GetSettingStr(NameDB, “Catalog”, “aaa”)

dbDataSource = SetIni.GetSettingStr(NameDB, “DataSource”, sky)

cnStr= “Provider=SQLOLEDB.1;Password=” & dbPassword & “;Persist Security Info=True;User ID=” & dbUserID & “;Initial Catalog=” & dbCatalog & “;Data Source=” & dbDataSource ‘

其它由你自己补充了。

下面是一个VB6的类的源代码,来自国外网站的一个技术专家,类名:CSetting,可以读写ini配置文件,或者卖行卖读写注册表配带掘置。

Option Explicit

‘Settings interface class

‘Copyright ?Stan Schultes

‘Written for VBPJ Getting Started September, 2023

‘CSetting mode enum

Public Enum csModes

csModeRegistry = 0

csModeINI = 1

End Enum

‘class member variables

Private m_eSaveMode As csModes

‘module-level variables

Private msININame As String’name of .INI file

Private msAppName As String’app name for settings

‘INI setting APIs

Private Declare Function GetPrivateProfileInt Lib “kernel32” Alias “GetPrivateProfileIntA” (ByVal SectionName As String, ByVal KeyName As String, ByVal Default As Long, ByVal FileName As String) As Long

Private Declare Function GetPrivateProfileString Lib “kernel32” Alias “中逗GetPrivateProfileStringA” (ByVal SectionName As String, ByVal KeyName As String, ByVal Default As String, ByVal ReturnedString As String, ByVal StringSize As Long, ByVal FileName As String) As Long

Private Declare Function WritePrivateProfileString Lib “kernel32” Alias “WritePrivateProfileStringA” (ByVal SectionName As String, ByVal KeyName As String, ByVal KeyValue As String, ByVal FileName As String) As Long

‘there is no WritePrivateProfileInt declaration…

‘Error definitions

Private Const mklErrOffset As Long = vbObjectError + 512

Private Const mklErrNotNumeric As Long = mklErrOffset + 1

Private Const mksErrNotNumeric As String = “The setting value returned was not numeric”

Private Const mklErrWriting As Long = mklErrOffset + 2

Private Const mksErrWriting As String = “Error writing Setting “

Private Const mklErrReading As Long = mklErrOffset + 3

Private Const mksErrReading As String = “Error reading Setting “

Public Function Init(Optional ByVal AppPath As String, Optional ByVal AppName As Variant, Optional ByVal Mode As csModes = csModeRegistry)

‘Set up class variables, default to Registry mode

If IsMissing(AppPath) Then

msININame = App.Path

Else

msININame = Trim$(AppPath)

End If

If IsMissing(AppName) Then

msAppName = App.EXEName

Else

msAppName = Trim$(AppName)

End If

‘default to the app’s .exe path

msININame = msININame & “\” & msAppName & “.ini”

‘ msININame = App.Path & “\” & msAppName & “.ini”

SaveMode = Mode

End Function

Public Function GetSettingStr(ByVal Section As String, ByVal KeyName As String, ByVal DefaultValue As String) As String

‘returns a string setting

Dim lRet As Long

Dim sBuf As String * 128

On Error GoTo GetSettingStr_Error

If Len(msAppName) = 0 Then Init

Select Case m_eSaveMode

Case csModeRegistry

GetSettingStr = GetSetting(msAppName, Section, KeyName, DefaultValue)

Case Else

lRet = GetPrivateProfileString(Section, KeyName, DefaultValue, sBuf, Len(sBuf), msININame)

GetSettingStr = TrimNull(sBuf)

End Select

GetSettingStr_Exit:

Exit Function

GetSettingStr_Error:

Err.Raise mklErrReading, “CSetting.GetSettingStr”, mksErrReading & “(” & Err & “, ” & Error & “)”

End Function

Public Function GetSettingInt(ByVal Section As String, ByVal KeyName As String, ByVal DefaultValue As Integer) As Integer

‘returns a numeric setting

Dim sSetting As String

On Error GoTo GetSettingInt_Error

If Len(msAppName) = 0 Then Init

Select Case m_eSaveMode

Case csModeRegistry

sSetting = GetSetting(msAppName, Section, KeyName, CStr(DefaultValue))

‘check if value is numeric

If IsNumeric(sSetting) Then

GetSettingInt = CInt(sSetting)

Else

‘match behavior of .INI return

GetSettingInt = 0

‘or – return error if desired

‘On Error GoTo’disable handler to return error

‘Err.Raise mklErrNotNumeric, “CSetting.GetSettingInt”, mksErrNotNumeric

End If

Case Else

‘returns 0 if not numeric

GetSettingInt = GetPrivateProfileInt(Section, KeyName, DefaultValue, msININame)

End Select

GetSettingInt_Exit:

Exit Function

GetSettingInt_Error:

Err.Raise mklErrReading, “CSetting.GetSettingInt”, mksErrReading & “(” & Err & “, ” & Error & “)”

End Function

Public Sub SaveSettingStr(ByVal Section As String, ByVal KeyName As String, ByVal Setting As String)

‘saves a string setting

Dim lRet As Long

On Error GoTo SaveSettingStr_Error

If Len(msAppName) = 0 Then Init

Select Case m_eSaveMode

Case csModeRegistry

SaveSetting msAppName, Section, KeyName, Setting

Case Else

lRet = WritePrivateProfileString(Section, KeyName, Setting, msININame)

End Select

SaveSettingStr_Exit:

Exit Sub

SaveSettingStr_Error:

Err.Raise mklErrWriting, “CSetting.SaveSettingStr”, mksErrWriting & “(” & Err & “, ” & Error & “)”

End Sub

Public Sub SaveSettingInt(ByVal Section As String, ByVal KeyName As String, Setting As Integer)

‘saves a numeric setting

Dim lRet As Long

On Error GoTo SaveSettingInt_Error

If Len(msAppName) = 0 Then Init

Select Case m_eSaveMode

Case csModeRegistry

SaveSetting msAppName, Section, KeyName, CStr(Setting)

Case Else

lRet = WritePrivateProfileString(Section, KeyName, CStr(Setting), msININame)

End Select

SaveSettingInt_Exit:

Exit Sub

SaveSettingInt_Error:

Err.Raise mklErrWriting, “CSetting.SaveSettingInt”, mksErrWriting & “(” & Err & “, ” & Error & “)”

End Sub

Public Property Let SaveMode(Mode As csModes)

‘sets save mode, see csModes enum

m_eSaveMode = Mode

End Property

Public Property Get SaveMode() As Long

‘returns save mode

SaveMode = CLng(m_eSaveMode)

End Property

Private Function TrimNull(ByVal InString As String) As String

‘trims string at first Null character

Dim lPos As Long

TrimNull = Trim$(InString)

lPos = InStr(TrimNull, vbNullChar)

If lPos > 0 Then TrimNull = Left$(TrimNull, lPos – 1)

End Function

Private Sub Class_Initialize()

msININame = App.Path & “\” & App.EXEName & “.ini”

End Sub

使用方法:

在程序的全局模块中定义CSetting的类实例变量:(以下定义了两个,分别读写ini和注册表)

Public SetIni As CSetting ‘读写ini配置文件参数’

Public SetReg As CSetting’读写注册表配置参数

在sub main 中初始化:(其中PATH_EXE是你的程序路径,放ini文件的路径)

Set SetIni = New CSetting

SetIni.Init PATH_Exe, App.Title, csModeINI

Set SetReg = New CSetting

SetReg.Init PATH_Exe, App.Title, csModeRegistry

这就可以随便用了。

dbPassword = SetIni.GetSettingStr(NameDB, “Password”, “111111”)

dbUserID = SetIni.GetSettingStr(NameDB, “UserID”, “123456”)

dbCatalog = SetIni.GetSettingStr(NameDB, “Catalog”, “aaa”)

dbDataSource = SetIni.GetSettingStr(NameDB, “DataSource”, sky)

cnStr= “Provider=SQLOLEDB.1;Password=” & dbPassword & “;Persist Security Info=True;User ID=” & dbUserID & “;Initial Catalog=” & dbCatalog & “;Data Source=” & dbDataSource ‘

其它由你自己补充了。

ini文件的内容大致什么样子?

这兆颂个要给运前分,前面的族悄郑都答非所问

关于linux c 库版本的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

创新互联-老牌IDC、云计算及IT信息化服务领域的服务供应商,业务涵盖IDC(互联网数据中心)服务、云计算服务、IT信息化、AI算力租赁平台(智算云),软件开发,网站建设,咨询热线:028-86922220

网站名称:LinuxC库版本探究(linuxc库版本)
浏览地址:http://www.gawzjz.com/qtweb/news0/167450.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联