Best Constant Placement

  • In a multi-source C application, which is the best place to put constant values, the source file itself or its header file? If the constant will be used only in this source file.

  • Is this a good way to save static constin header files?

+4
source share
1 answer
  • Do not disclose information that you do not need. If the constant is a detail of the implementation of a single compilation unit, there is no need to pollute the global namespace. You can always add it to the title later if necessary.

  • . static . , extern .

+5

All Articles