GCC-3.4.6源代码学习笔记(20)

3.2.2. 准备处理编译命令选项

在创建了cpp_reader对象后,c_common_init_options最后确认要编译的语言,并初始化相关的数据结构。这个函数最终将确认的语言返回。

 

c_common_init_options (continue)

 

210    cpp_opts = cpp_get_options (parse_in);

211    cpp_opts ->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;

212    cpp_opts ->objc = c_dialect_objc ();

213 

214    /* Reset to avoid warnings on internal definitions. We set it just

215      before passing on command-line options to cpplib.  */

216    cpp_opts ->warn_dollars = 0;

217 

218    flag_const_strings = c_dialect_cxx ();

219    flag_exceptions = c_dialect_cxx ();

220    warn_pointer_arith = c_dialect_cxx ();

221 

222    deferred_opts = xmalloc (argc * sizeof (struct deferred_opt));

223 

224    result = lang_flags[c_language];

225 

226    if (c_language == clk_c)

227    {

228      for (i = 1; i < argc; i++)

229      {

230        /* If preprocessing assembly language, accept any of the C-family

231          front end options since the driver may pass them through.  */

232        if (! strcmp (argv[i], "-lang-asm"))

233          result |= CL_C | CL_ObjC | CL_CXX | CL_ObjCXX;

234  #ifdef CL_F77

235        /* If potentially preprocessing Fortran we have to accept its

236          front end options since the driver may them through.  */

237        else if (! strcmp (argv[i], "-traditional-cpp"))

238        {

239          permit_fortran_options = true;

240          result |= CL_F77;

241        }

242  #endif

243      }

244    }

245    return result;

246  }

 

cpp_opts是一个全局变量,它指向cpp_readeropts域。函数cpp_get_options仅返回这个域。c_dialect_cxx则检查语言是否支持C++。上面,flag_const_stringsflag_exceptionswarn_pointer_arithdeferred_opts都是全局变量。其中,flag_const_strings如果为非0值,表示给定的字符串为const char *类型,正如标准要求那样。flag_exceptions如果为非0值,表示为产生异常处理的代码使其能工作。warn_pointer_arith如果为非0值,表示对sizeof (function)或含有函数指针的加减法给出警告。而defer_opt保存由c_common_handle_option 解析的编译选项,但这些选项的处理要推迟到函数c_common_post_options中。

 

你可能感兴趣的:(数据结构,c,assembly,语言,fortran,Warnings)