glib

GLIB: g_atomic_int_get becomes NO-OP?

£可爱£侵袭症+ 提交于 2020-01-02 08:24:25
问题 In a larger piece of code, I noticed that the g_atomic_* functions in glib were not doing what I expected, so I wrote this simple example: #include <stdlib.h> #include "glib.h" #include "pthread.h" #include "stdio.h" void *set_foo(void *ptr) { g_atomic_int_set(((int*)ptr), 42); return NULL; } int main(void) { int foo = 0; pthread_t other; if (pthread_create(&other, NULL, set_foo, &foo)== 0) { pthread_join(other, NULL); printf("Got %d\n", g_atomic_int_get(&foo)); } else { printf("Thread did

What's the difference between glib gunichar and wchar_t and which is better for cross-platform solutions?

假装没事ソ 提交于 2020-01-02 04:07:21
问题 I'm trying to write some C code which is portable only so far as the user has gcc , and has glib installed. From all my research, I've found that with gcc , a wchar_t is always defined as 4 bytes, and with glib a gunichar is also 4 bytes. What I haven't figured out is if like a gunichar , a wchar_t is encoded as UCS4 as well. Is this the case? If so, I should be able to simply cast a gunichar* to a wchar_t* and use the stdc wcs* functions, right? 回答1: If you use GLib, don't use wchar_t . Use

How can I find the length of a given GArray?

雨燕双飞 提交于 2020-01-02 02:43:32
问题 I have a GArray of GValue (all non-zero) which has been allocated at runtime with g_array_append_val. I wonder how can I find out what's the index of the last element, or more precisely how many elements does the array hold. Code like for (length=0;g_value_get_int(&g_array_index(array, GValue, length)); length++); return length would fail with an out of bounds. 回答1: It doesn't seem to be well-documented, but the number of the elements in the array is stored in the field array->len . 来源: https

Glib use in an iPhone App

孤人 提交于 2020-01-01 17:11:48
问题 I would like to develop an iPhone App based on an existing open-source Objective-C framework, however that framework makes extensive use of the glib library and I cannot find a way to build and include the glib library for an iPhone app (non jailbreak). Is there any way this can be done, or is there any recommended approach to porting a framework away from glib? Thanks 回答1: I would recommend porting away from because glib is GPL licensed, which means that you will have to open source all your

How Do I Run ./configure with MinGW?

。_饼干妹妹 提交于 2019-12-31 12:53:16
问题 I am looking at this webpage http://mathieu.carbou.free.fr/wiki/index.php?title=Glib_for_Win32 And it tells me I need to run the following commands. ./configure make make install How do I actually do this and where can I find these files. I have MinGW and Mysys installed in my C drive. 回答1: On Windows there is 2 ways to achieve this if you have MinGW installed you also have to install msys for MinGW some MinGW installations already come pre-installed with msys to check go to your MinGW folder

Is OS detection possible with GLib?

谁说我不能喝 提交于 2019-12-31 03:19:30
问题 Is it possible to determine on which platform (GNU/Linux, Win32, OS X) my Vala app is running? 回答1: As Vala is a compiled language (as opposed to intermediate or interpreted) you can determine the platform using your favorite build tool and use conditional compilation. Something like: #if WINDOWS message ("Running on Windows"); #elif OSX message ("Running on OS X"); #elif LINUX message ("Running on GNU/Linux"); #elif POSIX message ("Running on other POSIX system"); #else message ("Running on

安装TiDB的mydumper报required 'glib-2.0' found

不羁的心 提交于 2019-12-26 13:39:50
公司采用mysql,mongodb,es,redis等数据库和NoSQL产品,需要集中所有数据到中间库TiDB,为以后数据仓库抽取数据做好准备. 在TiDB官网下载mydumper软件, https://github.com/maxbube/mydumper 解压后,按照官方文档 cmake . ,然后 make ,最后 make install centos 7.6版本,TiDB mydumper 0.10.0, built against MySQL 5.5.64-MariaDB 版本下,会出现下面问题: CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:363 (message): None of the required ‘glib-2.0’ found 根据官网记载,安装下面组件则可以解决该问题. Fedora, RedHat and CentOS: yum install glib2-devel mysql-devel zlib-devel pcre-devel openssl-devel 来源: CSDN 作者: jacobxian 链接: https://blog.csdn.net/jacobxian/article/details/103712806

gdbus-monitor - interface `<none>`

瘦欲@ 提交于 2019-12-25 07:08:02
问题 Has the interface <none> in the gdbus-monitor output a special meaning? What API call is required to create such a message using GDbus ( g_dbus_connection_register_object does not allow to pass NULL as GDBusInterfaceInfo * and that seems to be the only to register a object to a path) related: dbus - register object to remote on interface NULL 回答1: Looking into dbus-monitor 's source code shows that it occures as soon as DBUS_EXPORT const char * dbus_message_get_interface ( DBusMessage *

flex+bison output in a glib's hash container

倾然丶 夕夏残阳落幕 提交于 2019-12-25 05:05:24
问题 I have managed considerable progress in parsing the bib file, but the next step is quite tough for my present level of understanding. I have created bison and flex code, that parses the bib file above correctly: %{ #include <stdio.h> %} // Symbols. %union { char *sval; }; %token <sval> VALUE %token <sval> KEY %token OBRACE %token EBRACE %token QUOTE %token SEMICOLON %start Input %% Input: /* empty */ | Input Entry ; /* input is zero or more entires */ Entry: '@' KEY '{' KEY ','{ printf("=====

flex+bison output in a glib's hash container

假装没事ソ 提交于 2019-12-25 05:05:05
问题 I have managed considerable progress in parsing the bib file, but the next step is quite tough for my present level of understanding. I have created bison and flex code, that parses the bib file above correctly: %{ #include <stdio.h> %} // Symbols. %union { char *sval; }; %token <sval> VALUE %token <sval> KEY %token OBRACE %token EBRACE %token QUOTE %token SEMICOLON %start Input %% Input: /* empty */ | Input Entry ; /* input is zero or more entires */ Entry: '@' KEY '{' KEY ','{ printf("=====