Reputation: 6140
What I am looking for seems to be basic but I have no idea about checking types without producing error.
How can I check if type uint
does not exist then define it as unsigned int
?
Upvotes: 1
Views: 266
Reputation: 7644
Typically, you would put it in your own namespace.
You can using
that namespace, if there is a collision the user can
specify with the scope operator (::
). Often, library vendors
let user have the option to not using
the namespace with a macro.
(Or more commonly the reverse)
Checking if uint
already exist, and conditionally define it if
it does not, can only be done if you can be sure it is defined
as a macro, something that rarely holds in c++
If it is a fundamental type, you can use for example std::uint32_t
from <cstdint>
.
Upvotes: 1