gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
What is a good C naming convention for global variables?
- User
What is a good C naming convention for global variables?
- Assistant
A good C naming convention for global variables could be using a prefix or a combination of prefixes to indicate their scope or purpose. This helps to clearly distinguish global variables from local variables.
Some common prefixes used for global variables are:
- "g_" or "s_" (e.g., g_variableName, s_anotherVariable) - indicating global or shared variables.
- "gP_" or "sP_" (e.g., gP_variableName, sP_anotherVariable) - indicating global or shared pointers.
- "g_XXX_" (e.g., g_configEnabled, g_networkAddress) - indicating a global variable pertaining to a specific module or functionality.
It is important to choose prefixes that align with the project's coding style and ensure consistency throughout the codebase.