There is a problem when I compile the case with -lcrypt
Andreas Schwab
schwab@linux-m68k.org
Fri Sep 4 09:40:00 GMT 2015
Cui Bixuan <cuibixuan@huawei.com> writes:
> int main() {
> char *c, *s;
> long int i;
>
> s="9223372036854775807";
> strtol(s, &c, 0);
>
> printf("errno=%d\n",errno);
>
> return 0;
> }
>
> Then I compile and run it in arm64 system:
>
> aarch64-linux-gnu-gcc test.c -o test
> aarch64-linux-gnu-gcc test.c -o test-1 -lcrypt
>
> ./test
> errno=0
>
> ./test-1
> errno=2
>
> I don't know why? Is this a problem?
The value of errno is unspecified except after a function call that is
documented to set errno _and_ that function call returned a failure
condition. Additionally, some functions like strtol are documented to
not modify errno if they return sucessfully. If you want to check for
failure for such a function you need to set errno to zero before the
call.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
More information about the Libc-alpha
mailing list