For whence parameter of fseek (or lseek in POSIX), some languages that calls C lib assume SEEK_SET, SEEK_CUR, SEEK_END are 0,1,2, respectively, such as gfortran, Nim [^py].
[^py]: while Python's seek specializes concrete values of SEEK_*, CPython does map 0,1,2 to C lib's values internally.
I've looked up C and POSIX specialization, neither specializes concrete values of SEEK_*.
In code, I wonder in which OS and C compiler, the following code's output isn't 012:
#include <stdio.h>
int main(){
printf("%d%d%d\n", SEEK_SET, SEEK_CUR, SEEK_END);
}
I've tested on some OSes and C compilers, where the output is just 012:
- Windows: gcc(mingw), MSVC
- Debian: clang, gcc
- FreeBSD: clang
- Solaris(SunOS5): Oracle Solaris Studio C Compiler
- Android(Termux): clang
And if there're none, then it's less meaningful to add fix for the existing implementations using fixed values.
SEEK_*values differSEEK_*. I wonder if they'll fail on some libraries/OSesSEEK_macros