Don't you really get any diagnostics at all? Every single warning from C compiler is significant, they're usually signs of grave errors! Also, when you do ask on Stack Overflow, please copy any diagnostics from the compiler verbatim into the question.
The problem is here:
fwrite(fin_val, sizeof(fin_val), 1, file);
The prototype of fwrite
is
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
The first argument must be a pointer to const void, yet you pass in a uint16_t
. It should be &fin_val
, so that fwrite
gets the address to that variable.
On a related note, fclose;
is not a function call, and this too should have produced a diagnostic message in any sane compiler. It should be fclose(file);
.
Here's an example output from GCC without warnings:
% gcc -c pcm.c
pcm.c: In function ‘write2PCM’:
pcm.c:10:12: warning: passing argument 1 of ‘fwrite’ makes pointer from integer without a
cast [-Wint-conversion]
fwrite(fin_val,sizeof(fin_val),1,file);
^~~~~~~
and here with all warnings enabled:
% gcc -c pcm.c -Wall
pcm.c: In function ‘write2PCM’:
pcm.c:10:12: warning: passing argument 1 of ‘fwrite’ makes pointer from integer without a
cast [-Wint-conversion]
fwrite(fin_val,sizeof(fin_val),1,file);
^~~~~~~
In file included from pcm.c:1:0:
/usr/include/stdio.h:717:15: note: expected ‘const void * restrict’ but argument is of
type ‘uint16 {aka short unsigned int}’
extern size_t fwrite (const void *__restrict __ptr, size_t __size,
^~~~~~
pcm.c:13:1: warning: statement with no effect [-Wunused-value]
fclose;}
^~~~~~