..\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?
Surely, it doesn't need any translation?
But it is impossible to guess which declaration, and which function it is referring to without seeing the relevant source line(s)!
Are you sure that you included the header at an appropriate position...?
I wouldn't ask for a translation if I didn't need one.
I know what the error was caused by. It was missing the definition of the tm struct in <time.h>.
What I don't understand is why I wouldn't just get an undefined reference error.
I would like to understand how the compiler interpreted this to end up with this error.
In order to understand that, it would be necessary to see exactly what you gave to the compiler to cause it.
As you haven't shown that, it is impossible to tell!
"I know what the error was caused by. It was missing the definition of the tm struct in <time.h>."
When you've had one error like that, it almost certainly means that the compiler is "out-of-sync" with your source text from that point on - it is therefore pointless worrying about subsequent errors, as they are almost certainly affected by the initial error.
If you've fixed the "tm struct" error, and then all the other messages just "magically" disappear, that confirms that they were all just consequences of that one error.
Move along now - nothing (more) to see here...
I get that you can't explain it.
I'm still interested though.
I would really be interested too. I can't directly see what source code error that would motivate the error message.
Something declared within a function is intended to be only visible within the function, so there should not be any warning.
Do you have any data types declared in any of your functions? In case the compiler saw tm being declared somewhere else in the code, it might have decided to be overly clever and warn that your undefined global tm use could not be matched with the local definition int saw somewhere else. But in that case, the compiler should have been so clever that it showed the other line number too.
Not without seeing your actual source code, of course.
But I very much suspect that it is as I suggested: your initial error(s) due to the missing header have thrown the compiler so far out-of-sync with your source text that it is giving apparently meaningless messages.
Sometimes it can get so grossly out-of-sync that it will actually crash!
If you really want to pursue it, you need to look at the point of the very first error and ask yourself what the compiler is assuming was there - having rejected what you actually wrote as invalid, and so on...
But, as I said, it is pointless - just fix the original error, and that will naturally fix all the consequent errors!
That's probably because nothing has directly caused it; it is probably caused "indiectly" as a result of the compiler getting out-of-sync with the source text because of the original error(s) due to the missing header(s).
No. There are situations where this happens, and causes all kinds of weird messages from the compiler. But this is not one of them.
The warning message under discussion is fully justified, and its text points exactly at the problem.
View all questions in Keil forum