Jump to content
  • Advertisement
Sign in to follow this  
ziruz

Using same names in different namespaces

This topic is 4971 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!