# Weird assertion error when im trying to create a new window

**URL:** <https://discourse.glfw.org/t/weird-assertion-error-when-im-trying-to-create-a-new-window/2519>\
**Category:** support\
**Created:** [December 15, 2023, 9:33am UTC](https://discourse.glfw.org/t/weird-assertion-error-when-im-trying-to-create-a-new-window/2519 "2023-12-15T09:33:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaybeELEMENT](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/maybeelement/32/853_2.png) [@MaybeELEMENT](https://discourse.glfw.org/u/MaybeELEMENT)\
**Post date:** [December 15, 2023, 9:33am UTC](https://discourse.glfw.org/t/weird-assertion-error-when-im-trying-to-create-a-new-window/2519/1 "2023-12-15T09:33:36Z")

</div>

Hello, i have the following code:

```auto
glfwSetErrorCallback(error_callback);
	if (!glfwInit())
	{
		printf("Failed to initialize GLFW\n");
		return -1;
	}
	engine.gameWin = glfwCreateWindow(engine.width, engine.height, engine.GetTitle().c_str(), NULL, NULL);
	if (engine.gameWin == NULL)
	{
		printf("Failed to create GLFW Window.\n");
		glfwTerminate();
		return -1;
	}

```

engine.width, engine,height and engine.GetTitle() is all not empty or null. They have their default value set.  
and it compiled successfully but when i try to run it i get this error:

```auto
Assertion failed: (window != NULL), function glfwSetWindowTitle, file window.c, line 498.

```

What is the issue here? Please help me!

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [December 15, 2023, 10:16am UTC](https://discourse.glfw.org/t/weird-assertion-error-when-im-trying-to-create-a-new-window/2519/2 "2023-12-15T10:16:13Z")

</div>

I think you might not be posting the full source code, since the error is in the function `glfwSetWindowTitle` which I can’t see in your code snippet, and it’s not called internally by GLFW.

I wonder what your function `engine.GetTitle()` does and could this somehow be calling `glfwSetWindowTitle` before the window is created, so `engine.gameWin` is `NULL`?

---

<div class="post-metadata">

**Author:** ![MaybeELEMENT](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/maybeelement/32/853_2.png) [@MaybeELEMENT](https://discourse.glfw.org/u/MaybeELEMENT)\
**Post date:** [December 15, 2023, 10:46am UTC](https://discourse.glfw.org/t/weird-assertion-error-when-im-trying-to-create-a-new-window/2519/3 "2023-12-15T10:46:53Z")

</div>

I just solved it. I forgot to let it check whether the gameWin is null or not before setting the title. Thanks alot! 😁
