New SE. Currently, we are improving the existing system written in C language.

In work,
I need to define a new common constant in an existing common header file.
In this case, can an existing program that references this header file be affected (for example, a build error)?

If i change a header file, i am reluctant to make changes to improve because all programs that reference the file will be retested.
I think that it is logically possible that there is no impact on existing programs in the case of additional modifications, not deletions, but is my opinion wrong?

  • Answer # 1

    There is an impact.

    The constant you write in the header file is probably a macro definition, right? In that case, if you don't make the name of the local variable obscured, it may cause a strange error.

    // foo.h
    // this macro definition results in an error
    #define foo 2
    # include
    #include "foo.h"
    int main () {
      int foo = 1;
      printf ("% d \ n", foo);
      return 0;

    In other words, it doesn't matter if you just don't cover the existing name. Verifying that the name you are trying to add is not already in use is only a matter of searching the source code, so it won't be a hassle.

    In general, there are many examples where macro names are not obscured by defining lexical conventions such as capitalizing.

    However, the testing procedure may be fixed if you do it in the business, so even if it seems that there is no problem with individual judgment, it is not unclear that exceptions are not easily accepted. That's a story that can be said to be solved by in-house remarks or political power, but I can't say technically.

    Personally, the problem is that the tests are not fully automated.

    From now on, it ’s a bit more ingenious than an answer to a question.


    macro will be replaced without question and answer everywhere as long as the names match, so it should be avoided if possible. It is a good practice to make it a variable withconst. However, if that happens, variables defined elsewhere (not header files) will be used asexternin the header file.

    If the constant isint, there are some ideas such as enumeration constants.

    // foo.h
    enum {
      foo = 2

    No question-and-answer replacement at the lexical level will occur.

  • Answer # 2

    If you can say it ’s possible, it ’s possible

    If you are wearing keywords that are used in the code,
    Or, if you are wearing a define keyword in your code, it will have such an effect

    Now, you need to search frequently for new keywords to make sure they are n’t being used