Let's say I Have a header file test.h.
#pragma once
extern uint64_t a;
void foo( uint64_t );
In my case, uint64_t is used to represent a Bitboard as a part of my chess engine
test.h
Naturally I will be using uint64_t everywhere. I wanted to create a type alias for uint64_t, as Bitboard.
So I did
using uint64_t = Bitboard;
But since this is a header file, Bitboard is now defined everywhere, since this header file is used by almost all the other files of the project.
The problem is that I only want to use this alias in test.h.
The problem
The project isn't small, and Bitboard isn't a very unique identifier, I feel a global alias like this can cause some collisions, and hence I want to strictly keep it within test.h.
Is there any way I can still use create something in a header file, and not have it leak into all the other files of my project?
typedefinstead ofusing. A question to ask yourself is why this header is used by all the rest of your project. Maybe you have an organizational problem.typedef, and notusing. I have organized functions into namespaces, but I do want something like a type alias to be only visible in the source of my header file and not any other file that might use it! I will edit the question and explain the issue.uint64_t? Or what about the code calling these functions using variables?