Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename function vs undef : conflicts with Windows API

This has actually occurred twice now. I'm writing a cross-platform application, and some of my function names conflict with the Windows API. What I did (for example with LoadObject) was...

#undef GetObject

Is this an okay approach, or should I rename my functions?

like image 453
person Avatar asked Nov 05 '22 08:11

person


2 Answers

If you intend for your code to be used alongside of the Windows API, I'd recommend renaming the functions. Yes, that's a hassle, but it's (in my opinion) better than undefining parts of the Windows API, even if you don't use those parts (someone else using your code might need to use those parts).

like image 164
James McNellis Avatar answered Nov 09 '22 16:11

James McNellis


You could put your functions in a namespace or a class (if applicable). If you are calling within a class then remember the this keyword. this->aliasedFunction();

like image 22
Kyle Avatar answered Nov 09 '22 14:11

Kyle