제출 #1142177

#제출 시각아이디문제언어결과실행 시간메모리
1142177otesunki비교 (balkan11_cmp)C11
컴파일 에러
0 ms0 KiB
static inline void *cheeze_ptr(void *fn, char prefix[2]) { char *check = (char *) fn; while (memcmp(check, prefix, 2)) ++check; unsigned int offset = *(unsigned int *) &check[3]; return &check[offset + 7]; } void remember(int n) {} int compare(int b) { int *guessval = cheeze_ptr(&bit_get, (char [2]) { 0x48, 0x63 }); return b<*guessval ? -1 : b==*guessval ? 0 : 1; }

컴파일 시 표준 에러 (stderr) 메시지

cmp.c: In function 'cheeze_ptr':
cmp.c:3:10: warning: implicit declaration of function 'memcmp' [-Wimplicit-function-declaration]
    3 |   while (memcmp(check, prefix, 2))
      |          ^~~~~~
cmp.c:1:1: note: include '<string.h>' or provide a declaration of 'memcmp'
  +++ |+#include <string.h>
    1 | static inline void *cheeze_ptr(void *fn, char prefix[2]) {
cmp.c:3:32: warning: 'memcmp' argument 3 type is 'int' where 'long unsigned int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch]
    3 |   while (memcmp(check, prefix, 2))
      |                                ^
<built-in>: note: built-in 'memcmp' declared here
cmp.c: In function 'compare':
cmp.c:12:31: error: 'bit_get' undeclared (first use in this function)
   12 |   int *guessval = cheeze_ptr(&bit_get, (char [2]) { 0x48, 0x63 });
      |                               ^~~~~~~
cmp.c:12:31: note: each undeclared identifier is reported only once for each function it appears in