How can I set options in SConstruct for C compiler depending on compiler type?

百般思念 提交于 2019-12-07 06:53:43

问题


I need to set additional options for C compiler, e.g. add flag to turn all warnings ON, depending on the type of the compiler. E.g. for MSVC I should use

env.Append(CPPFLAGS = "/Wall")

but for mingw (gcc) I need to use:

env.Append(CCFLAGS = "-Wall") 

How can I do this in scons way?


回答1:


You could just check for the name of the compiler:

cc = env['CC']
if cc == 'cl':
  env.Append(CPPFLAGS = '/Wall')
elif cc == 'gcc':
  env.Append(CCFLAGS = '-Wall')


来源:https://stackoverflow.com/questions/1961164/how-can-i-set-options-in-sconstruct-for-c-compiler-depending-on-compiler-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!