For this small test program:
#include <stdio.h>
void main(void){
char buffer[]="ABCDEFGHIJKLM NOPQRSTUVWXYZ\n ";
int size, count;
size = 27; /* always a small number which will fit in an int */
count = 1; /* ditto */
(void) fwrite(buffer, size, count, stdout);
}
The int variables size and count are both used for fwrite() arguments
which are prototyped to be size_t. If size_t is bigger than int (as on
some 64 bit systems where size_t is 8 bytes and int is 4 bytes), does
the C standard require the compiler to promote these two int values to
size_t before passing them to the function, and if so, what exactly does
it say?
I know that in _practice_ the code above works, but I am curious if that
must always be the case.
Thanks,
David Mathog
#include <stdio.h>
void main(void){
char buffer[]="ABCDEFGHIJKLM NOPQRSTUVWXYZ\n ";
int size, count;
size = 27; /* always a small number which will fit in an int */
count = 1; /* ditto */
(void) fwrite(buffer, size, count, stdout);
}
The int variables size and count are both used for fwrite() arguments
which are prototyped to be size_t. If size_t is bigger than int (as on
some 64 bit systems where size_t is 8 bytes and int is 4 bytes), does
the C standard require the compiler to promote these two int values to
size_t before passing them to the function, and if so, what exactly does
it say?
I know that in _practice_ the code above works, but I am curious if that
must always be the case.
Thanks,
David Mathog
Comment