1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>

/* HELPER FUNCTIONS
 */
void print_integer(int n, int radix, char* prefix) {  // PUBLIC
    _print_digit(n, radix);
    // COMPILER ERROR at ↑ this line because gcc has not read the declaration for
    // _print_digit(…) so it doesn't know what it takes.
    //
    // "implicit declaration of function ‘_print_digit’"
    // - means compiler does not know what _print_digit(…) takes and returns
    //    - because it is not declared (and defined) until later in the file.
}

// OK to copy/adapt this function signature
static void _print_digit(int digit_value, int radix) {  // HELPER function
    // TODO
}  

/*
d.c: In function ‘print_integer’:
d.c:9:2: warning: implicit declaration of function ‘_print_digit’ [-Wimplicit-function-declaration]
  _print_digit(n, radix);
  ^~~~~~~~~~~~
d.c: At top level:
d.c:15:13: warning: conflicting types for ‘_print_digit’
 static void _print_digit(int digit_value, int radix) {  // HELPER function
             ^~~~~~~~~~~~
d.c:15:13: error: static declaration of ‘_print_digit’ follows non-static declaration
d.c:9:2: note: previous implicit declaration of ‘_print_digit’ was here
  _print_digit(n, radix);
  ^~~~~~~~~~~~
d.c:15:13: warning: ‘_print_digit’ defined but not used [-Wunused-function]
 static void _print_digit(int digit_value, int radix) {  // HELPER function
*/
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2022 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.