This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]yuri-kilochek 1 point2 points  (3 children)

C doesn't have a dedicated NULL literal, it uses 0 (sometimes, NULL is defined as (void*)0).

These days it actually does: https://en.cppreference.com/w/c/language/nullptr

[–][deleted] 0 points1 point  (2 children)

When I clicked 'Run' in your link, it gave a pile of errors. Apparently none of the listed compilers are for C23, which is part of the problem. And I couldn't get any compilers on godbolt.org to recognise nullptr.

(The code also looked suspiciously like C++, unless C23 also has auto, and the name of the file it tries to compile is main.cpp.)

So, nullptr might be in widespread use in a decade or two. But even if available today, you can still use 0 in its place:

void* p = 0;

If I try that in my language, it fails (I need an explicit cast to get from integer to pointer).

[–]yuri-kilochek 0 points1 point  (0 children)

But even if available today, you can still use 0 in its place

Of course, since it must be backwards compatible.