문제

I have defined macros in my pre-compiled header file as well as in another header file named Constants.h.

Which is the better way, and why?

도움이 되었습니까?

해결책

Personally I wouldn't recommend the precompiled headers approach for many reasons, check here:

http://qualitycoding.org/precompiled-headers/

Apple uses the precompiled headers for AppKit, UIKit, Foundation, CoreData,... because there are hundreds of *.h files that don't change at all in every compilation of you app. Your custom macros, however, take just a few bytes and the overhead is negligible (Unless you have hundreds or thousands of macros)

다른 팁

The better way is .h file cause it will always be compiled. pch file is precompiled and can lead to problems when changes occurred but it didn't rebuild the pch part.

In addition to that it is just more convenient to have every global constant in an constant.h file and not distributed over many files.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top