Hello,
Somebody can explain strange behaviour of this code on i386 and amd64 platform FreeBSD?
test.c
on the first host:
at the second host:
What the difference ( Without taking in the follow sample for "-W" Warning level in cc ) between i386/amd64 ?
Thanks!
Somebody can explain strange behaviour of this code on i386 and amd64 platform FreeBSD?
test.c
Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/sysctl.h>
int main()
{
unsigned int physmem=0;
size_t len;
len = sizeof(physmem);
if (sysctlbyname("hw.physmem", &physmem, &len, NULL, 0) == -1)
printf("sysctlbyname ;(",0);
else printf("%d",physmem);
}
on the first host:
Result (it correct numbers byte for my RAM):% sysctl hw.machine_arch kern.osrelease
hw.machine_arch: i386
kern.osrelease: 7.1-PRERELEASE
% cc test.c -o test
% ./test
Code:
1592954880
at the second host:
Result:% sysctl hw.machine_arch kern.osrelease
hw.machine_arch: amd64
kern.osrelease: 7.1-PRERELEASE
% cc test.c -o test
test.c: In function 'main':
test.c:11: warning: passing argument 3 of 'sysctlbyname' from incompatible pointer type
% ./test
Code:
sysctlbyname ;(
What the difference ( Without taking in the follow sample for "-W" Warning level in cc ) between i386/amd64 ?
Thanks!