Function Macro


since: 2.0


#define g_warning (


A convenience function/macro to log a warning message. The message should typically not be translated to the user’s language.

This is not intended for end user error reporting. Use of GError is preferred for that instead, as it allows calling functions to perform actions conditional on the type of error.

Warning messages are intended to be used in the event of unexpected external conditions (system misconfiguration, missing files, other trusted programs violating protocol, invalid contents in trusted files, etc.)

If attempting to deal with programmer errors (for example, incorrect function parameters) then you should use G_LOG_LEVEL_CRITICAL instead.

g_warn_if_reached() and g_warn_if_fail() log at G_LOG_LEVEL_WARNING.

You can make warnings fatal at runtime by setting the G_DEBUG environment variable (see Running GLib Applications):

  G_DEBUG=fatal-warnings gdb ./my-program

Any unrelated failures can be skipped over in gdb using the continue command.

If g_log_default_handler() is used as the log handler function, a newline character will automatically be appended to @…, and need not be entered manually.

If structured logging is enabled, this will use g_log_structured(); otherwise it will use g_log(). See [Using Structured Logging][using-structured-logging].

Available since: 2.0

This function is not directly available to language bindings.



Type: -

Format string, followed by parameters to insert into the format string (as with printf())