• MISRA C:2012 8 Rules 8.5 Identifiers 标识符


    3334 This declaration of '%s' hides a more global declaration.

    extern int press;
    
    void foo(void)
    {
        float press;               /* Message 3334 */
    }

    3448 Declaration of typedef '%s' is not in a header file although it is used in a definition or declaration with external linkage.

    typedef int TYPE;         /* Message 3448 */
    extern TYPE foo(void);    /* Message 3447 */
    
    extern TYPE foo(void)
    {
        return 1;
    }

    1525 Object/function with external linkage has same identifier as another object/function with internal linkage.

    file1.cpp
    =======
    extern int contr;    // Message 1525 
    
    file2.cpp
    =======
    static int contr;    // Message 1525

    这种写法是合法的,但是不建议这么写,如果上述代码写在同一个文件中,会报错。

    1526 Object with no linkage has same identifier as another object/function with external linkage.重名错误

    file1.cpp
    =======
    extern int remake;    // Message 1526 
    
    file2.cpp
    =======
    void foo(void)
    {
        int remake;      // Message 1526 
        ...
    }

    1527 Object/function with internal linkage has same identifier as another object/function with internal linkage.

    file1.cpp
    =======
    static int cra;    // Message 1527
    
    file2.cpp
    =======
    static int cra;    // Message 1527

    这么写合法,但是不建议这么写

    1528 Object with no linkage has same identifier as another object/function with internal linkage.

    file1.cpp
    =======
    static int cra;    // Message 1528 
    
    file2.cpp
    =======
    void foo(void)
    {
        int cra;       // Message 1528 
        ...
    }
  • 相关阅读:
    Eclipse用法和技巧二:自动生成Main方法1
    java 基于JDK中的源码总结下String二
    700.Search in a Binary Search Tree
    722.Remove Comments
    95. Unique Binary Search Trees II(dfs经典题目)
    20.Valid Parentheses
    28.Implement strStr()
    888.Fair Candy Swap
    14.Longest Common Prefix
    234.Palindrome Linked List
  • 原文地址:https://www.cnblogs.com/focus-z/p/11666680.html
Copyright © 2020-2023  润新知