autosar吧 关注:134贴子:80
  • 7回复贴,共1

有关代码生成的问题

只看楼主收藏回复

懂AUTOSAR的大神们
问个很弱智的问题
在看AUTOSAR_EXP_ModelingShowCases的时候发现里面的代码总是用
P2VAR(),CONSTP2CONST()这种宏起头
很明显这种宏不是手写上去的
那这些代码使用什么软件生成出来的呢
AUTOSAR开发是不是遵循这种编码格式比较好啊


1楼2017-11-02 09:43回复
    Look at this long expression of function declaration
    extern FUNC( Std_ReturnType, FEE_CODE ) Fee_Write(
    VAR( uint16, AUTOMATIC ) BlockNumber,
    P2VAR( uint8, AUTOMATIC, FEE_APPL_DATA ) DataBufferPtr);
    There are four macro in this expression: FUNC, VAR, P2VAR, Std_ReturnType, these definition
    /*
    * @Violates @贴吧用户_007CeS5🐾 Compiler_h_REF_4 In the definition of a function-like macro each instance of a
    * parameter shall be enclosed in parentheses
    */
    #define FUNC(rettype, memclass) rettype
    /*
    * @violates @ref Compiler_h_REF_4 In the definition of a function-like macro each instance of a
    * parameter shall be enclosed in parentheses
    */
    #define VAR(vartype, memclass) vartype
    /*
    * @violates @ref Compiler_h_REF_4 In the definition of a function-like macro each instance of a
    * parameter shall be enclosed in parentheses
    */
    #define P2VAR(ptrtype, memclass, ptrclass) ptrtype *
    /**
    * @Brief This type can be used as standard API return type which is shared between the RTE and the
    * BSW modules.
    * @implements DBASE12002
    */
    typedef uint8 Std_ReturnType;
    So the long declaration expression should look like this after precompile :
    extern uint8 Fee_Write(uint16 BlockNumber, uint8* DataBufferPtr);
    It’s simple, So don’t be scared by the long expression.
    PS: AUTOSAR <Specification of Compiler Abstraction> defined how to implement the Complier.h file.


    IP属地:上海来自Android客户端2楼2019-02-22 16:50
    收起回复
      可以


      IP属地:中国香港3楼2019-05-06 09:25
      回复
        可以关注下b站阿隆汽车


        IP属地:上海4楼2023-06-07 15:17
        回复