Default argument promotions in C function calls

前端 未结 3 514
小蘑菇
小蘑菇 2020-11-22 05:15

Setup

I have a few questions about the default argument promotions when calling a function in C. Here\'s section 6.5.2.2 \"Function calls\" Paragraphs 6, 7, and 8

3条回答
  •  温柔的废话
    2020-11-22 06:08

    Your confusion stems from a very slight misunderstanding of the terminology - both declarations and definitions can include prototypes (or not):

    void func(int a, char b, float c);
    

    That is a function declaration that includes a prototype.

    void func(int a, char b, float c) { /* ... */ }
    

    That is a function definition that includes a prototype.

    "Prototyped" and "non-prototyped" are just attributes of a function type, and both declarations and definitions introduce the type of the function.

    So you can have a declaration without a prototype:

    void func();
    

    or you can have a definition without a prototype (K&R C style):

    void func(a, b, c)
        int a;
        char b;
        float c;
    { /* ... */ }
    

提交回复
热议问题