Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何分别给 c代码和 C++代码设定编译参数 #4844

Closed
Guozhanxin opened this issue Jul 3, 2021 · 8 comments
Closed

如何分别给 c代码和 C++代码设定编译参数 #4844

Guozhanxin opened this issue Jul 3, 2021 · 8 comments

Comments

@Guozhanxin
Copy link
Member

按照下面这种写法,先把 CFlags 赋值给 CXXFlags,然后再单独给 CFlag 添加参数。编译时,新添加的参数仍然会传递给 CXX 编译器。
bsp: stm32-f429-apollo
编译器:armclang.

elif PLATFORM == 'armclang':
    # toolchains
    CC = 'armclang'
    CXX = 'armclang'
    AS = 'armasm'
    AR = 'armar'
    LINK = 'armlink'
    TARGET_EXT = 'axf'

    DEVICE = ' --cpu Cortex-M4.fp '
    CFLAGS = ' --target=arm-arm-none-eabi -mcpu=cortex-m4 '
    CFLAGS += ' -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 '
    CFLAGS += ' -mfloat-abi=hard -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar '
    CFLAGS += ' -gdwarf-3 -ffunction-sections '
    AFLAGS = DEVICE + ' --apcs=interwork '
    LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers '
   ...
    CXXFLAGS = CFLAGS
    CFLAGS += ' -std=c99'

    POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
@thewon86
Copy link
Contributor

thewon86 commented Jul 5, 2021

把特别的部分分离成库,多项目协作

@BernardXiong
Copy link
Member

这部分好像问题是出现在SConstruct里,

env = Environment(tools = ['mingw'],
    AS   = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
    CC   = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
    CXX  = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
    AR   = rtconfig.AR, ARFLAGS = '-rc',
    LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)

其中的CCFLAGS是代表了C和C++的参数,需要分离开来。但是目前所有BSP似乎都是CCFLAGS了……

@Guozhanxin
Copy link
Member Author

CXXFLAGS 

如果 CCFLAGS 是C和C++公共的参数,那 CFLAGS 和 CXXFLAGS 就应该包含各自独立的参数了?比如 ' -xc' 和 ' -xc++'

@Guozhanxin
Copy link
Member Author

#2855

@mysterywolf
Copy link
Member

#4953

@liukangcc
Copy link
Member

#5171

@mysterywolf
Copy link
Member

#5397

@mysterywolf
Copy link
Member

#5411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants