This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

被一句带有class的define语句给难住了,求解惑



TM4C的c编程,在查看IntEnable( INT_TIMER0A )这个函数的时候,查到里面包含这样的一些宏定义:

其中的INT_TIMER0A是这么定义的:

#define INT_TIMER0A         INT_CONCAT(INT_TIMER0A_, INT_DEVICE_CLASS)

这其中的符号是这么定义的:

#define INT_DEVICE_CLASS        "UNKNOWN"

#define INT_CONCAT(intname, class)     INT_RESOLVE(intname, class)

#define INT_RESOLVE(intname, class)     intname##BLIZZARD

 

看不懂这里面的class关键字是做什么的?C里面有class这个关键字吗?

 

提前感谢了!

 

另外附件一句:本来像Cortex M4这样的处理直接控制寄存器什么问题不是都直接了当吗,为什么TI高了这个tivaware,有的地方写得真是晦涩难懂,

感觉已经脱离了C控制硬件的本事了,成了C的技巧游戏了!

 

 

  • 那里面的intname,class明显是个参数,不是系统关键字吧。class是C++关键字,脱离硬件,不正是库的本质么,话说,有时候不得不吐槽,TI的库,确实是自己的风格,和主流的STM32的不一样。

  • 没有看到有class关键字,c里面也没有这个关键字,如果你是说#define INT_CONCAT(intname, class)中的class的话,那是一个参数变量

  • 你就知足吧,你去看看freescale的,你就知道,其实TI的库已经很好用了

  • 我也被难住了,这个class显示为蓝色,看起来是个关键字呀。。。这个宏定义是什么样意思,有人能解答一下吗?

    谢谢!

  • 你用的是MDK,这个选择c++编程的话,这个应该是关键字。

  • 大神,你知道下面这个宏是什么意思吗?

    #INT_RESOLVE(intname, class)    intname##SNOWFLAKE

    intname我知道,指的是前面括号里的参数,但是后面的那个名字我ctrl+f在整个工程中搜索了一遍,只有这一行。。

    这行代码在Tivaware的hw_ints.h中的第333行。

  • 你在哪找的了,我找到hw_ints.h没找到你说的这个宏定义和字符

    //*****************************************************************************
    //
    // hw_ints.h - Macros that define the interrupt assignment on Stellaris.
    //
    // Copyright (c) 2005,2006 Luminary Micro, Inc.  All rights reserved.
    //
    // Software License Agreement
    //
    // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
    // exclusively on LMI's Stellaris Family of microcontroller products.
    //
    // The software is owned by LMI and/or its suppliers, and is protected under
    // applicable copyright laws.  All rights are reserved.  Any use in violation
    // of the foregoing restrictions may subject the user to criminal sanctions
    // under applicable laws, as well as to civil liability for the breach of the
    // terms and conditions of this license.
    //
    // THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
    // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
    // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
    // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
    // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
    //
    // This is part of revision 991 of the Stellaris Driver Library.
    //
    //*****************************************************************************
    
    #ifndef __HW_INTS_H__
    #define __HW_INTS_H__
    
    //*****************************************************************************
    //
    // The following define the fault assignments.
    //
    //*****************************************************************************
    #define FAULT_NMI               2           // NMI fault
    #define FAULT_HARD              3           // Hard fault
    #define FAULT_MPU               4           // MPU fault
    #define FAULT_BUS               5           // Bus fault
    #define FAULT_USAGE             6           // Usage fault
    #define FAULT_SVCALL            11          // SVCall
    #define FAULT_DEBUG             12          // Debug monitor
    #define FAULT_PENDSV            14          // PendSV
    #define FAULT_SYSTICK           15          // System Tick
    
    //*****************************************************************************
    //
    // The following define the interrupt assignments.
    //
    //*****************************************************************************
    #define INT_GPIOA               16          // GPIO Port A
    #define INT_GPIOB               17          // GPIO Port B
    #define INT_GPIOC               18          // GPIO Port C
    #define INT_GPIOD               19          // GPIO Port D
    #define INT_GPIOE               20          // GPIO Port E
    #define INT_UART0               21          // UART0 Rx and Tx
    #define INT_UART1               22          // UART1 Rx and Tx
    #define INT_SSI                 23          // SSI Rx and Tx
    #define INT_I2C                 24          // I2C Master and Slave
    #define INT_PWM_FAULT           25          // PWM Fault
    #define INT_PWM0                26          // PWM Generator 0
    #define INT_PWM1                27          // PWM Generator 1
    #define INT_PWM2                28          // PWM Generator 2
    #define INT_QEI                 29          // Quadrature Encoder
    #define INT_ADC0                30          // ADC Sequence 0
    #define INT_ADC1                31          // ADC Sequence 1
    #define INT_ADC2                32          // ADC Sequence 2
    #define INT_ADC3                33          // ADC Sequence 3
    #define INT_WATCHDOG            34          // Watchdog timer
    #define INT_TIMER0A             35          // Timer 0 subtimer A
    #define INT_TIMER0B             36          // Timer 0 subtimer B
    #define INT_TIMER1A             37          // Timer 1 subtimer A
    #define INT_TIMER1B             38          // Timer 1 subtimer B
    #define INT_TIMER2A             39          // Timer 2 subtimer A
    #define INT_TIMER2B             40          // Timer 2 subtimer B
    #define INT_COMP0               41          // Analog Comparator 0
    #define INT_COMP1               42          // Analog Comparator 1
    #define INT_COMP2               43          // Analog Comparator 2
    #define INT_SYSCTL              44          // System Control (PLL, OSC, BO)
    #define INT_FLASH               45          // FLASH Control
    
    //*****************************************************************************
    //
    // The total number of interrupts.
    //
    //*****************************************************************************
    #define NUM_INTERRUPTS          46
    
    //*****************************************************************************
    //
    // The total number of priority levels.
    //
    //*****************************************************************************
    #define NUM_PRIORITY            8
    #define NUM_PRIORITY_BITS       3
    
    #endif // __HW_INTS_H__