Sign in to follow this  
ziruz

Using same names in different namespaces

Recommended Posts

ziruz    122
Hi, just started to write some code for a flexible file system that can handle pack files and other stuff like mounting dirs and network resources... My problem is how i should name my functions. I have the whole file system in a namespace FS, there i want to have function like OpenFile and CloseFile these names is also aviable in windows so this might be confussing. Is it ok to reuse the names in a namespace? if i reuse the names it possibly can be problem with the use of using namespace FS; if this is used then there will be conflicts... i usualy dont use the using namespace but someone else might do that and that can put them in troble... How do i best name my routins? // ziruz

Share this post


Link to post
Share on other sites
chollida1    532
If you want to use the same names, you still won't get collisions unless your methods has the same signature as the windows methods.

If they do then that's exactly what namespaces where intended for... to prevent nameing collisions.

CHeers
Chris

Share this post


Link to post
Share on other sites
SiCrane    11839
I strongly recommend against resuing windows API functions in your projects. The fine gentlemen at Microsoft decided to implement narrow and wide character versioning of many of their API functions via preprocessor macros, which means that if some source files include windows headers and others don't, you can get annoying macro replacement issues that don't show up until link time when they seem completely irrational.

Though to be honest, OpenFile() seems to be one of the funcitons that don't come in both A and W versions, and would probably safe to use as a name.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this