Преглед на файлове

fix: 修复了使用gcc编译器无法编译args的问题

SongZihuan преди 4 години
родител
ревизия
c3874ac47b
променени са 2 файла, в които са добавени 5 реда и са изтрити 7 реда
  1. 3 5
      argument/argument.c
  2. 2 2
      include/arguement.h

+ 3 - 5
argument/argument.c

@@ -18,6 +18,8 @@ static const struct option long_option[]={
 
 static const char *short_option = "o:e:i:n";
 
+Args args = {.out_file=NULL, .error_file=NULL, .in_file=NULL, .run_commandLine=true};
+
 /**
  * 参数设置, args是全局结构体, 保存全局的参数设置
  * @param argc
@@ -26,12 +28,8 @@ static const char *short_option = "o:e:i:n";
  */
 int getArgs(const int argc, char **argv)
 {
-    args.out_file = NULL;
-    args.error_file = NULL;
-    args.in_file = NULL;
-    args.run_commandLine = true;
-    opterr = true;
     int opt;
+    opterr = true;
     while((opt=getopt_long(argc, argv, short_option ,long_option,NULL))!=-1)
     {
         switch(opt)

+ 2 - 2
include/arguement.h

@@ -8,8 +8,8 @@ struct Args{
     char *out_file;
     char *in_file;
     bool run_commandLine;
-} args;
-
+};
+extern struct Args args;
 typedef struct Args Args;
 
 int getArgs(int argc, char **argv);