Mein C sagt:
1 | E:\Programme\arduino\portable\sketchbook\sketch_feb01d\t.c: In function 'test':
|
2 | E:\Programme\arduino\portable\sketchbook\sketch_feb01d\t.c:13:5: warning: implicit declaration of function 'nop' [-Wimplicit-function-declaration]
|
3 | 13 | nop();
|
4 | | ^~~
|
5 | E:\Programme\arduino\portable\sketchbook\sketch_feb01d\t.c: In function 'main':
|
6 | t.c:18:12: error: unknown type name 'I2C_STATUS_CODE_t'
|
7 | 18 | volatile I2C_STATUS_CODE_t status;
|
8 | | ^~~~~~~~~~~~~~~~~
|
9 | t.c:19:12: error: 'I2C_STATUS_OK' undeclared (first use in this function); did you mean 'STATUS_OK'?
|
10 | 19 | status = I2C_STATUS_OK;
|
11 | | ^~~~~~~~~~~~~
|
12 | | STATUS_OK
|
13 | E:\Programme\arduino\portable\sketchbook\sketch_feb01d\t.c:19:12: note: each undeclared identifier is reported only once for each function it appears in
|
14 | E:\Programme\arduino\portable\sketchbook\sketch_feb01d\t.c:20:8: warning: passing argument 1 of 'test' from incompatible pointer type [-Wincompatible-pointer-types]
|
15 | 20 | test(&status);
|
16 | | ^~~~~~~
|
17 | | |
|
18 | | volatile int *
|
19 | E:\Programme\arduino\portable\sketchbook\sketch_feb01d\t.c:9:42: note: expected 'volatile STATUS_CODE_t *' but argument is of type 'volatile int *'
|
20 | 9 | static void test(volatile STATUS_CODE_t *status)
|
21 | | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
|
22 | exit status 1
|
23 | unknown type name 'I2C_STATUS_CODE_t'
|
Und mein C++ sagt:
1 | E:\Programme\arduino\portable\sketchbook\sketch_feb01d\sketch_feb01d.ino: In function 'void test(volatile STATUS_CODE_t*)':
|
2 | sketch_feb01d:11:14: error: no match for 'operator==' (operand types are 'volatile STATUS_CODE_t*' and 'STATUS_CODE_t')
|
3 | 11 | if (status == STATUS_OK)
|
4 | | ~~~~~~ ^~ ~~~~~~~~~
|
5 | | | |
|
6 | | | STATUS_CODE_t
|
7 | | volatile STATUS_CODE_t*
|
8 | sketch_feb01d:13:5: error: 'nop' was not declared in this scope
|
9 | 13 | nop();
|
10 | | ^~~
|
11 | E:\Programme\arduino\portable\sketchbook\sketch_feb01d\sketch_feb01d.ino: In function 'int main()':
|
12 | sketch_feb01d:18:12: error: 'I2C_STATUS_CODE_t' does not name a type; did you mean 'STATUS_CODE_t'?
|
13 | 18 | volatile I2C_STATUS_CODE_t status;
|
14 | | ^~~~~~~~~~~~~~~~~
|
15 | | STATUS_CODE_t
|
16 | sketch_feb01d:19:3: error: 'status' was not declared in this scope; did you mean 'static'?
|
17 | 19 | status = I2C_STATUS_OK;
|
18 | | ^~~~~~
|
19 | | static
|
20 | sketch_feb01d:19:12: error: 'I2C_STATUS_OK' was not declared in this scope; did you mean 'STATUS_OK'?
|
21 | 19 | status = I2C_STATUS_OK;
|
22 | | ^~~~~~~~~~~~~
|
23 | | STATUS_OK
|
24 | E:\Programme\arduino\portable\sketchbook\sketch_feb01d\sketch_feb01d.ino: At global scope:
|
25 | E:\Programme\arduino\portable\sketchbook\sketch_feb01d\sketch_feb01d.ino:9:13: warning: 'void test(volatile STATUS_CODE_t*)' defined but not used [-Wunused-function]
|
26 | 9 | static void test(volatile STATUS_CODE_t *status)
|
27 | | ^~~~
|
28 | exit status 1
|
29 | no match for 'operator==' (operand types are 'volatile STATUS_CODE_t*' and 'STATUS_CODE_t')
|
Natürlich darf man einen Pointer prüfen, ob er Null ist.
Aber das will man hier ja wohl nicht, einen Pointer auf Null prüfen,
sondern das worauf er zeigt.
C ist da weniger pingelig, als C++.