MDK中armclang编译器

本文介绍了在MDK和DS5工具中,armclang编译器逐渐取代armcc的趋势。作者在尝试使用armclang编译STM32工程,特别是结合ST的Cube HAL库时遇到了问题,如'__weak'未定义的错误。解决方案是手动在stm32f1xx_hal_def.h文件中添加armclang编译器的定义,以解决编译不通过的问题。
摘要由CSDN通过智能技术生成

MDK以及DS5等工具中主推的编译器已经更换为armclang编译器。而原来的armcc编译器已经不再更新,只是提供一些更新,所以我就对armclang进行了一些测试。

测试的芯片是STM32,使用ST公司最新推出的Cube HAL库。直接新建一个工程之后,直接将编译器更改为armclang编译不通过。

错误一:提供找不到‘__weak’

解决方案:"__weak"的定义是在stm32f1xx_hal_def.h文件中。其中有关于各种编译器的定义部分。理论上armclang应该是会定义__GNU__的,可能由于MDK的bug或是其它原因,这部分并没有定义,所以需要手动增加针对armclang编译器的定义。

修改后代码如下:

 

/**
  ******************************************************************************
  * @file    stm32f1xx_hal_def.h
  * @author  MCD Application Team
  * @version V1.1.1
  * @date    12-May-2017
  * @brief   This file contains HAL common defines, enumeration, macros and 
  *          structures definitions. 
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  *
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
  *   1. Redistributions of source code must retain the above copyright notice,
  *      this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright notice,
  *      this list of conditions and the following disclaimer in the documentation
  *      and/or other materials provided with the distribution.
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
  *      may be used to endorse or promote products derived from this software
  *      without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT N
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值