Moving printerror() & reportError() declaration to global?

Moving printerror() & reportError() declaration to global?

Return to topic list

Sat Jul 27 06:40:29 2024   by   Mizuki
calling printerror from reportError is an implicit out of scope declaration as printerror is only defined inside int main.
Maybe it'd be a good idea to move the two function declaration to outside int main (to global)?
 
Tue Jul 30 10:00:08 2024   by   Torben
Both functions are global, but located at the end of the file.  So you can call them from anywhere, as long as you make forward declarations before or inside the function from which you call them.
 
Tue Jul 30 10:39:56 2024   by   Mizuki
Hmm, that might be because I kind of modernize the code a little bit, compiling your original version didn't reveal that error (just old style declaration warnings)
This is the warning on my end
planet.c:2436:2: warning: use of out-of-scope declaration of
      'printerror' whose type is not compatible with that of an implicit declaration [-Wout-of-scope-function]
2436 |        printerror();
      |        ^
planet.c:268:46: note: previous declaration is here
  268 |        void printhelp(void), reportError(char c), printerror(void);
      |
 

Return to topic list



New message:
Topic:
Posted by:

Type the values of the dice shown below:

Return to topic list