I defined const UInt8 HE = he; inside namespace Ports in ports.h. Then I included it in ports_logic.h and in ports_logic.h, I have the following code inside namespace Ports
#ifndef HP
const UInt8 HP = hp;
#endif
However during compilation, it gives me the following error.
What is the alternative to ifndef that can help me check if the const int HP has already been defined?
Thanks.

You're confusing the preprocessor and the compiler. Declaring a C++ variable does not define anything in the preprocessor. Let's look line-by-line:
This is handled by the preprocessor. The only way for this to fail is by
#define HPor similar. The C++ compiler never sees this line.This is handled by the C++ compiler after the preprocessor has done its thing. The preprocessor ignores this line.
There is no direct way to do what you want; the ideal solution is to arrange your project in a way that
HPwill never be declared more than once. It should be declared in a single translation unit, and exposed asexternin header files.