---
name: "xcb_create_gc"
section: "3"
platform: "linux"
package: "libxcb"
version: "1.17.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/xcb_create_gc"
---

# xcb\_create\_gc(3)

Creates a graphics context

## NAME

xcb\_create\_gc - Creates a graphics context

## SYNOPSIS

**#include \<xcb/xproto.h\>**

### Request function

xcb\_void\_cookie\_t **xcb\_create\_gc**(xcb\_connection\_t \**conn*, xcb\_gcontext\_t *cid*, xcb\_drawable\_t *drawable*, uint32\_t *value\_mask*, const void \**value\_list*);\

## REQUEST ARGUMENTS

- *conn*

  The XCB connection to X11.

- *cid*

  The ID with which you will refer to the graphics context, created by *xcb\_generate\_id*.

- *drawable*

  Drawable to get the root/depth from.

- *value\_mask*

  TODO: NOT YET DOCUMENTED.

- *value\_list*

  TODO: NOT YET DOCUMENTED.

## DESCRIPTION

Creates a graphics context. The graphics context can be used with any drawable that has the same root and depth as the specified drawable.

## RETURN VALUE

Returns an *xcb\_void\_cookie\_t*. Errors (if any) have to be handled in the event loop.

If you want to handle errors directly with *xcb\_request\_check* instead, use *xcb\_create\_gc\_checked*. See **[xcb-requests(3)](/xcb-requests/3.md)** for details.

## ERRORS

- *xcb\_alloc\_error\_t*

  The X server could not allocate the requested resources (no memory?).

- *xcb\_drawable\_error\_t*

  The specified *drawable* (Window or Pixmap) does not exist.

- *xcb\_font\_error\_t*

  TODO: reasons?

- *xcb\_match\_error\_t*

  TODO: reasons?

- *xcb\_pixmap\_error\_t*

  TODO: reasons?

- *xcb\_value\_error\_t*

  TODO: reasons?

## SEE ALSO

[**xcb-requests**(3)](/xcb-requests/3.md), **xcb\_generate\_id**(3)

## AUTHOR

Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements.
