summaryrefslogtreecommitdiffstats
path: root/iwyu_getopt.h
blob: 1a0c69780daf9e74e6f6e31970efaecc4fc247ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//===--- iwyu_getopt.h - OS-specific implementation of getopt for IWYU ----===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef INCLUDE_WHAT_YOU_USE_IWYU_GETOPT_H_
#define INCLUDE_WHAT_YOU_USE_IWYU_GETOPT_H_

#if defined(_MSC_VER)

// Hand-rolled implementation of getopt/getopt_long for Visual C++.
extern const int no_argument;
extern const int required_argument;
extern const int optional_argument;

extern char* optarg;
extern int optind, opterr, optopt;

struct option {
  const char* name;
  int has_arg;
  int* flag;
  int val;
};

int getopt(int argc, char* const argv[], const char* optstring);

int getopt_long(int argc, char* const argv[],
  const char* optstring, const struct option* longopts, int* longindex);

#else  // #if defined(_MSC_VER)

#include <getopt.h>   // IWYU pragma: export

#endif  // #if defined(_MSC_VER)

#endif  // INCLUDE_WHAT_YOU_USE_IWYU_GETOPT_H_