Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent constant for C++ NULL in Delphi?

Tags:

c++

winapi

delphi

I need to migrate my C++ codes to Delphi. There are many checks to check if a given handle(HANDLE) is NULL or not in C++ codes. What is the equivalent constant that can be used in Delphi? It seems that null in Delphi is different from NULL in C++.

like image 449
alancc Avatar asked Oct 19 '18 08:10

alancc


1 Answers

In the Windows C++ header files, NULL is a macro that expands to 0. This means that NULL can be used in both numeric and pointer contexts, because the C++ language supports such usage.

However, for Delphi, the value 0 is used in numeric contexts, and the value nil is used in pointer contexts.

Windows HANDLE values are declared in Delphi as numeric types and so in place of C++ NULL you should use 0 in Delphi.

like image 163
David Heffernan Avatar answered Nov 23 '22 19:11

David Heffernan