Glib utility and error handling function @ GTK + 2.0 Chinese tutorial serialization

Source: Internet
Author: User
Tags gtk
<Previous Glib Next >>>
Utilities and error handling functions
gchar *g_strdup( const gchar *str );

Replace the strdup function. Copy the original string content to the new storage block and return a pointer to it.

gchar *g_strerror( gint errnum );

I recommend using this function to handle all error messages. It is better and more portable than perror () and other similar functions. The output of this function is usually in the following format:

program name:function that failed:file or further description:strerror

Here is an example of calling this function in our hello_world program:

g_print("hello_world:open:%s:%s/n", filename, g_strerror(errno));
void g_error( gchar *format, ... );

Print the error message. The format is the same as that of printf, but "** error **" is added before the error message and the program is exited. It is used only for fatal errors.

void g_warning( gchar *format, ... );

Similar to the previous function, the error message is "** warning **" and does not exit the program.

void g_message( gchar *format, ... );

Print "message:" Before the passed string :"

void g_print( gchar *format, ... );

Replace the printf () function.

The last function in this chapter:

gchar *g_strsignal( gint signum );

Print the corresponding signal name for the given signal number. It is useful in common signal processing functions.

All of the above function bodies are more or less obtained from glib. H. If anyone is interested in the documentation of a function, just send me an email.

<Previous Home Next >>>
String processing Up RC file of GTK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.