Declaring aliases in multiple files

Hi,

I am curious whether we need to declare single alias in both the header and cpp file separately.
For example using int32 = int; is included in the header file, then is it necessary to write the same again in the cpp file?
It seems to work even if we don’t write it again. So is it because of coding standards?

Just need to declare an alias once. Typically, I have all constants, enums, aliases, and such, in their own header file, each with the:

#ifndef filename_assigned_hpp
#define filename_assigned_hpp 

    .... contents

#endif /* filename_assigned_hpp */

and remember to replace filename_assigned portion appropriately

1 Like

Ok thanks for clearing that up.
I see you are using header guards in your header files. What about the #pragma once?
Is it a personal preference or a compiler compatibility?

When XCode generates the class files, it uses the #ifndef manner of ensuring unique definition. XCode and Visual Studio both support #pragma once.

I wonder if there’s a configuration setting for using one or the other?

1 Like

Privacy & Terms