This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

..\display.h(72): warning: #231-D: declaration is not visible outside of function

..\display.h(72): warning: #231-D: declaration is not visible outside of function

I got message when I included a header file containing this line:

void DISPLAY_string_date_time(const struct tm * tim, DISPLAY_MSG * p_message);

I found the problem - I hadn't included <time.h> in the two cases that caused the warning.

After a lot of searching for what this warning means, I can't find any explanation.

Can anyone translate what the compiler is saying?

Parents
  • After a lot of searching for what this warning means, I can't find any explanation.

    You've already found all essential elements of the explanation. You just haven't connected the dots yet.

    The problem is in that header you included: it can't stand on its own feet. This header uses struct tm, which is a type defined in <time.h>. So it really should #include <time.h> to have it available.

    Since it didn't, the "struct tm *" in that function's argument list is a forward declaration of type struct tm, but one that only applies to the function prototype it's in. That's surely not what it was supposed to mean. I.e. the code doesn't do what its author is most likely to have intended. The compiler is absolutely correct warning you about it.

Reply
  • After a lot of searching for what this warning means, I can't find any explanation.

    You've already found all essential elements of the explanation. You just haven't connected the dots yet.

    The problem is in that header you included: it can't stand on its own feet. This header uses struct tm, which is a type defined in <time.h>. So it really should #include <time.h> to have it available.

    Since it didn't, the "struct tm *" in that function's argument list is a forward declaration of type struct tm, but one that only applies to the function prototype it's in. That's surely not what it was supposed to mean. I.e. the code doesn't do what its author is most likely to have intended. The compiler is absolutely correct warning you about it.

Children
No data