本文介绍了C 模拟转 STL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅仅因为我很好奇——是否有任何类似于 C++ 中 STL 功能的 C 模拟?我已经看到提到一个名为 glib 的 GTK+ 库,一些人认为它可以满足要求,但还有其他库可以满足会在 C 中提供 STL 功能吗?

Just because I'm curious--is there any C analog to the functionality of the STL in C++? I've seen mention of a GTK+ library called glib that a few people consider fills the bill but are there other libraries that would provide STL functionality in C?

推荐答案

是的,glib 是一个不错的选择:它包含许多用于操作容器(如链表、数组、哈希表)的实用程序等等. 还有一个叫做 GObject 的面向对象的框架,你可以用它在 C 中创建带有信号和槽的对象(尽管有相当冗长的函数调用名称,如 gobject_set_property>,因为 C 没有任何对象语法).并且还有主循环的代码,因此您可以编写事件驱动的程序.

Yes, glib is a pretty good choice: it includes a lot of utilities for manipulating containers like linked lists, arrays, hash tables, etc. And there is also an object-oriented framework called GObject that you can use to make objects with signals and slots in C (albeit with rather verbose function call names like gobject_set_property, since C doesn't have any syntax for objects). And there is also code for main loops so you can write event-driven programs.

有关更多信息,请参阅维基百科:https://en.wikipedia.org/wiki/GLib

For more info see wikipedia: https://en.wikipedia.org/wiki/GLib

Glib 最初是 GTK 的一部分,但非 GUI 代码已被完全分解,以便您可以在命令行程序中使用它:http://library.gnome.org/devel/glib/stable/

Glib was originally part of GTK, but the non-GUI code has been completely factored out so that you can use it in command-line programs: http://library.gnome.org/devel/glib/stable/

这篇关于C 模拟转 STL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 17:19