Advancing Arguments in C Function Calls

I learned from ---- As for when promotions are activated by default: promotions are used by default exactly when the expected type of argument is unknown, that is, when there is no prototype or when the argument is variable.

But the example confuses me:

void func(char a, char b)
{
    printf("a=%p,b=%p\n",&a,&b);    
}

int main(void)
{
    char a=0x11,b=0x22;

    func(a,b);

    return 0;
}

In the above example, it is clean: when calling func in main there is no need to advance the arguments a and b, but the output shows & a = & b +4 not & a = & b +1. If no advance occurred, why 4 bytes between two CHAR arguments?

+3
source share
1 answer

Because the compiler feels that it does it like this :-)

, , . , ( , ).

( ) , 4 , , , C.

+1

Source: https://habr.com/ru/post/1747835/


All Articles