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中。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值