Using same names in different namespaces

Started by
1 comment, last by SiCrane 19 years, 5 months ago
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
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
CheersChris
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.

This topic is closed to new replies.

Advertisement