LWJGL Forum

Programming => LWJGL Documentation => Topic started by: iamcreasy on May 22, 2018, 05:10:05

Title: Error in the getting started tutorial: window(long) is being compared to Null.
Post by: iamcreasy on May 22, 2018, 05:10:05
Hello. In the getting started tutorial available here : https://www.lwjgl.org/guide

Line 50 is the following,
if ( window == NULL )

But the variable window is declared as a primitive long in Line 17,
    private long window;

A primitive long can never be null. So is this a mistake in line 50?

-
Title: Re: Error in the getting started tutorial: window(long) is being compared to Null.
Post by: KaiHH on May 22, 2018, 05:51:02
NULL is not null. NULL instead is defined as a static field whose type is long and value is 0. It should resemble http://en.cppreference.com/w/cpp/types/NULL
Title: Re: Error in the getting started tutorial: window(long) is being compared to Null.
Post by: iamcreasy on May 22, 2018, 15:40:25
Oh I see. Thank you. It's a bit confusing though.
Title: Re: Error in the getting started tutorial: window(long) is being compared to Null.
Post by: KaiHH on May 22, 2018, 17:50:53
For a Java developer, maybe. But it shows that LWJGL also tries to attract C/C++ developers to the JVM platform by making it easy to adapt the vast amounts of familiar C/C++ OpenGL/GLFW examples/tutorials to the JVM/Java. It is (almost) really only copy and paste.
Title: Re: Error in the getting started tutorial: window(long) is being compared to Null.
Post by: iamcreasy on May 22, 2018, 18:56:33
Hmm, didn't think of it in that way. Interesting observation. Thank you.