Skip to content

Instantly share code, notes, and snippets.

@satta
Created July 1, 2020 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satta/abf66f4d28ea44b72e9601dd6d76ce57 to your computer and use it in GitHub Desktop.
Save satta/abf66f4d28ea44b72e9601dd6d76ce57 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main() {
int optind = 99, optreset = 98;
#if defined __GLIBC__
/* glibc needs to have optind set to 0 instead of the "traditional
value" of 1 */
optind = 0;
#else
/* 1 is the value that optind should be initialized to according to
IEEE Std 1003.1 */
optind = 1;
#if defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ || defined __APPLE__ || defined __DragonFly__
/* BSD-like libc also needs to have optreset set to 1 */
optreset = 1;
#endif
#endif
printf("ind %d reset %d\n", optind, optreset);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment